cfgcjm Posted July 31, 2008 Share Posted July 31, 2008 I'm trying to check if a session is started and no matter what, each time it echos:"session just started" <?PHP if(!isset($_SESSION)) { session_start(); echo'session just started'; } else{ echo'session already started'; } ?> Link to comment https://forums.phpfreaks.com/topic/117638-checking-session/ Share on other sites More sharing options...
DarkWater Posted July 31, 2008 Share Posted July 31, 2008 Because you need to use session_start() to access $_SESSION in the first place. Try: <?php session_start(); if ($_SESSION['started']) { echo "Session already started."; } else { $_SESSION['started'] = true; echo "Session just started."; } ?> Link to comment https://forums.phpfreaks.com/topic/117638-checking-session/#findComment-605055 Share on other sites More sharing options...
cooldude832 Posted July 31, 2008 Share Posted July 31, 2008 Because you need to use session_start() to access $_SESSION in the first place. Not technically if session.auto_start = 1 then the session_start() happens without it Link to comment https://forums.phpfreaks.com/topic/117638-checking-session/#findComment-605061 Share on other sites More sharing options...
DarkWater Posted July 31, 2008 Share Posted July 31, 2008 It's still calling session_start() behind the scenes. What was the point of bringing that up? o-O Link to comment https://forums.phpfreaks.com/topic/117638-checking-session/#findComment-605062 Share on other sites More sharing options...
cfgcjm Posted July 31, 2008 Author Share Posted July 31, 2008 either way...it works now, thanks! Link to comment https://forums.phpfreaks.com/topic/117638-checking-session/#findComment-605068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.