Jump to content


Photo

Session variables


  • Please log in to reply
8 replies to this topic

#1 robburne

robburne
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 06 April 2006 - 12:19 AM

Hi,

My installation of php running with my Apache server does not seem to be handling session variables correctly.

Scripts run on a different server fine with session variables working and accessible as expected.

Is there a something I need to enable in the php.ini?

Any help would be appreciated, I can post the php info if necessary.

Thanks in advance,

Rob.

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 April 2006 - 08:18 AM

sessions should work as soon as PHP is installed. How are you creating your sessions?

#3 robburne

robburne
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 06 April 2006 - 10:24 AM

[!--quoteo(post=362156:date=Apr 6 2006, 03:18 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 6 2006, 03:18 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
sessions should work as soon as PHP is installed. How are you creating your sessions?
[/quote]

As follows:

<?

session_start();

$_SESSION["variable"]="Some data";

?>

As I said on another server they work fine used in this manner.

Rob.



#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 April 2006 - 01:40 PM

So the above code you posted above works on your remote server but it doesnt work on your local server, which is installed on your PC?

If so does your local server have register_globals turned on, if it does turn it off? and does your local server have short_open_tag turned on too as short_open_tag (<?) is set to off by defualt.

#5 robburne

robburne
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 06 April 2006 - 09:13 PM

Hi,

Thanks for the reply.

I checked the php.ini and register_globals was set to off. I have now checged it as follows, here is the cut and paste from my php.ini file:

; This file is different from the php.ini-dist file in the fact that it features
; different values for several directives, in order to improve performance, while
; possibly breaking compatibility with the standard out-of-the-box behavior of
; PHP 3. Please make sure you read what's different, and modify your scripts
; accordingly, if you decide to use this file instead.
;
; - register_globals = on [Security, Performance]
;

I closed Apache and restarted it but I still cannot access the session variables. I also checked that short_open_tag is switched on.

Any ideas?

Rob.

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 April 2006 - 09:24 PM

Turn register_globals off, I swear I didn't say turn it on. This is what I said:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]If so, does your local server have register_globals turned on? if it does turn it off.[/quote]


[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]; This file is different from the php.ini-dist file in the fact that it features
; different values for several directives, in order to improve performance, while
; possibly breaking compatibility with the standard out-of-the-box behavior of
; PHP 3. Please make sure you read what's different, and modify your scripts
; accordingly, if you decide to use this file instead.
;
; - register_globals = on [Security, Performance]
;[/quote]
Umm, Thats not the way to enable/disable register_globals. To enable/disable register_globals the option is around line 447 in the php.ini file.

#7 robburne

robburne
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 06 April 2006 - 09:44 PM

[!--quoteo(post=362369:date=Apr 6 2006, 04:24 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 6 2006, 04:24 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Turn register_globals off, I swear I didn't say turn it on. This is what I said:
Umm, Thats not the way to enable/disable register_globals. To enable/disable register_globals the option is around line 447 in the php.ini file.
[/quote]

Thanks yes I realised that after posting, I found the line that had no semi-colon in front of it, I think I was editing the comments of the ini file.

I am testing a few things but I am sure it is still not working.

Rob.

#8 robburne

robburne
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 06 April 2006 - 10:07 PM

Hi,

I can confirm that around line 375 I am turning the globals on as follows:

register_globals = On

I have tried both on and off and my scripts do not work when accessing the session variables, 100% confirmed. Like I said same scripts on a differnet remote server work perfectly. This is very odd, any other ideas?

Thanks,

Rob.

#9 robburne

robburne
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 08 April 2006 - 04:15 PM

Hi,

I have register_globals turned off using the correct syntax but still no joy...... take a look at the two scripts which I am using to test, maybe there is a problem in my code?

First Script:

<?

session_start();

$_SESSION['test']="ROB";

echo"<a href=test2.php>TRESTING</a>";

?>


Second Script:

<?

session_start();

echo"$_SESSION['test']";

?>


The second script receives no data. I have a hammer in my hand and my server close by ;0)

Rob.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users