session varible undefined

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brcolow
Forum Newbie
Posts: 2
Joined: Sun Sep 29, 2002 7:25 pm

session varible undefined

Post by brcolow »

i have this line to validate a session..

Code: Select all

if (session_is_registered("valid_user"))

obviously because this is a windows machine it says undefined varbile, so should it be something like...

Code: Select all

if (session_is_registered("$HTTP_POST_VARSї'vaild_user]'))
But that doesnt work, how should i do this?
Thanks,
Brcolow
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

that should work, even on a windows machine. i use sessions on my WinXP dev server. perhaps you could show us the context that the code is used in. would help us better understand what you are trying to do.

also have a look at this: http://www.php.net/manual/en/function.s ... stered.php for it seems to have some good pointers on how to check if a variable is registered in the session.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Instead of using session_is_registered() try this if you are using PHP 4.0.6 or below:

Code: Select all

if (isset($HTTP_SESSION_VARSї'valid_user'])) {
or this if you are using PHP 4.1 or above:

Code: Select all

if (isset($_SESSIONї'valid_user'])) {
Mac
Post Reply