session_register fatal error.

Problems with the Windows version of XAMPP, questions, comments, and anything related.

session_register fatal error.

Postby evolvelab » 21. November 2012 19:17

Hi guys, new here.

This is the first time i have ever come accross this error, maybe because it's been a while since i upgraded...

session_register basically doesn't exist anymore...

this is the code i was using before...

Code: Select all
session_register('username');
$_SESSION['username'] = $inf->username;   


I basically want that, but a fully functioning version, can anybody help me?

Thanks
Kind Regards
Jake Duncan
evolvelab
 
Posts: 3
Joined: 21. November 2012 19:10
XAMPP Version: 5.6.3
Operating System: Windows 7 64Bit

Re: session_register fatal error.

Postby WilliL » 21. November 2012 19:40

Hi Jake,

session_register() is depredecate since PHP 5.3.0.
I would mark out this line. If I read http://php.net/manual/en/function.session-register.php right, your excample shows 2 times the same work. once in current forme and one in elder form.

If you would like to keep this line, I fear you have to use an elder verion of XAMPP
Willi
WilliL
 
Posts: 628
Joined: 08. January 2010 10:54
XAMPP Version: 5.5.19
Operating System: Win7Home Prem 64 SP1

Re: session_register fatal error.

Postby evolvelab » 21. November 2012 19:45

Hi Willi,

I have just seen

Code: Select all
<?php
// Use of session_register() is deprecated
$barney = "A big purple dinosaur.";
session_register("barney");

// Use of $_SESSION is preferred, as of PHP 4.1.0
$_SESSION["zim"] = "An invader from another planet.";

// The old way was to use $HTTP_SESSION_VARS
$HTTP_SESSION_VARS["spongebob"] = "He's got square pants.";
?>


from the link you added...

i have changed the line to

Code: Select all
$_SESSION["username"] = "$inf->username";


But a session still doesn't start...
It has boggled my brain, i know it must be something so simple.

Regards
Jake
evolvelab
 
Posts: 3
Joined: 21. November 2012 19:10
XAMPP Version: 5.6.3
Operating System: Windows 7 64Bit

Re: session_register fatal error.

Postby evolvelab » 21. November 2012 20:05

Ok, so i have fixed the problem,

had to make some minor changes in the script for it to work properly, but i figured it out!

Thanks!

For future reference, if anyone else stumbles accross this problem.. thats an IF.. because it's only me that stuff like this happens to lol

the fix is..

Code: Select all
session_start();


must obviously start at the beginning or before the following code,

You can use this, if you just wish to register the username as a session

Code: Select all
$_SESSION["username"] = "$variableforyourusername";


and it should work. :) Peace
evolvelab
 
Posts: 3
Joined: 21. November 2012 19:10
XAMPP Version: 5.6.3
Operating System: Windows 7 64Bit

Re: session_register fatal error.

Postby WilliL » 21. November 2012 21:13

http://php.net/manual/en/function.session-register.php
Code: Select all
If session_start() was not called before this function is called, an implicit call to session_start() with no parameters will be made. $_SESSION does not mimic this behavior and requires session_start() before use.


For i started php programming later I didn't knew that in earlier version you mustn't use "session_start();" ;)
Willi
WilliL
 
Posts: 628
Joined: 08. January 2010 10:54
XAMPP Version: 5.5.19
Operating System: Win7Home Prem 64 SP1


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 41 guests