snday Posted November 26, 2006 Share Posted November 26, 2006 I'm pretty sure the answer is yes, but want to be certain.Let me try to explain if you dont already understand from the title.I create a default session value for a user on my site, lets say the value is:$_SESSION['is_logged'] = TRUE;I then do certain checks with this session.Lets say I do not want a user to see something IF $_SESSION['is_logged'] == FALSE;When a user first visits the website, no session is created, but will on next pageload.Same for many Bots.. they dont generate sessions.So if I want to check $_SESSION['is_logged'] == FALSE;will it always return FALSE if that session is not there/not created? Link to comment https://forums.phpfreaks.com/topic/28507-will-non-existent-sessions-always-return-false/ Share on other sites More sharing options...
trq Posted November 26, 2006 Share Posted November 26, 2006 [code=php:0]$_SESSION['is_logged'] == FALSE[/code]Will allways return TRUE if the session has not been set. (Be carefull how you word things) Link to comment https://forums.phpfreaks.com/topic/28507-will-non-existent-sessions-always-return-false/#findComment-130445 Share on other sites More sharing options...
snday Posted November 26, 2006 Author Share Posted November 26, 2006 [quote author=thorpe link=topic=116341.msg473963#msg473963 date=1164548347][code=php:0]$_SESSION['is_logged'] == FALSE[/code]Will allways return TRUE if the session has not been set. (Be carefull how you word things)[/quote]crap,what I ment was the reverse.Basically I am wondering....If a Session is NOT created, it will always return FALSE if checking for it correct? Link to comment https://forums.phpfreaks.com/topic/28507-will-non-existent-sessions-always-return-false/#findComment-130448 Share on other sites More sharing options...
trq Posted November 26, 2006 Share Posted November 26, 2006 it will also generate a warning, your best to use....[code=php:0]if (isset($_SESSION['is_logged')) { // is set} else { // not set}[/code] Link to comment https://forums.phpfreaks.com/topic/28507-will-non-existent-sessions-always-return-false/#findComment-130454 Share on other sites More sharing options...
snday Posted November 26, 2006 Author Share Posted November 26, 2006 thanks :) Link to comment https://forums.phpfreaks.com/topic/28507-will-non-existent-sessions-always-return-false/#findComment-130456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.