Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undefined variable PSPSESSID ?!

Status
Not open for further replies.

Leozack

MIS
Joined
Oct 25, 2002
Messages
867
Location
GB
Help, I've just installed apache and php on my new XP sp1 setup. After getting everything working between the 2, I found a problem. My code has ain includes page taht does all the session work, and makes the variables if they're not already there. It starts with this :

if (!$PHPSESSID) {

Now - that always used to work, ie, if there isn't a session, make one. I've already got past problems of having sessions pointing to the wrong dir and stuff like that, and now teh files are being made correctly in /tmp but still thigns aren't working! It says undefined variable. Eh? The point in checking if it exists is to make it, not bomb out cos it doesn't exist O_o

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
The existence of $PHPSESSID is dependent on a lot more than whether the session has been started, not the least of which is the setting of register_globals in php.ini.

"register_globals" would have to be set to "on" for that variable to exist. Keep in mind, though, that the PHP online manual recommends leaving it set to "off" (
Want the best answers? Ask the best questions: TANSTAAFL!!
 
I noticed that was off in the latest PHP build ini by default, along with other things that I previously had on by default. Naturally I want to code with the secure settings and adjust to these new settings. So. What is the plan B that circumvents this problem?

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
When I'm checking to see whether a session variable has not been set, I do something like:

<?php
session_start();

if (!array_key_exists('foo', $_SESSION))
{
$_SESSION['foo'] = 'bar';
}
.
.
.
?>

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thanks, I was reading up about flock (which I also need to try to work into my site I guess) and the 5 super globals. I guess I will now have to start getting all my vars using the superglobals from where they're expected, something I've not done upto now. I shall probably also consider, as with programming in vb or blitz or div or anything else really, having a section at the top where I set all the variables initially, or a function that sets them so you can reset them at any time. Hmmm.

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
I have gotten myself into the habit of using the superglobals where possible.

Aside from the security reasons mentioned in hte &quot;Using register globals&quot; page, I've found that referencing the supergloblals adds a modicum of automatic documentation to my code. I may not remember where $foo got its value, but $_POST['foo'] is obvious.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top