Jump to content

Archived

This topic is now archived and is closed to further replies.

robburne

Session variables

Recommended Posts

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.

Share this post


Link to post
Share on other sites
sessions should work as soon as PHP is installed. How are you creating your sessions?

Share this post


Link to post
Share on other sites
[!--quoteo(post=362156:date=Apr 6 2006, 03:18 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 6 2006, 03:18 AM) [snapback]362156[/snapback][/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.

Share this post


Link to post
Share on other sites
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 [b]short_open_tag[/b] turned on too as [b]short_open_tag[/b] (<?) is set to off by defualt.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--quoteo(post=362369:date=Apr 6 2006, 04:24 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 6 2006, 04:24 PM) [snapback]362369[/snapback][/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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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:

[b]<?

session_start();

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

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

?>[/b]

Second Script:

[b]<?

session_start();

echo"$_SESSION['test']";

?>[/b]

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

Rob.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.