I am editing a site where the person has set it up so even though pages can't be viewed, there is no session checking... This is what is currently is there...
session_start(); should always be the first thing you do, unless of course one of your sessions in an object, then you need to define that object's class first - but I doubt you'll have to worry about that for quite some time
Of course this will only work providing that your logon script declares the var $_SESSION['user_logged'] with a boolean value properly. If the user has logged, $_SESSION['user_logged'] = TRUE; else $_SESSION['user_logged'] = FALSE.
Of course this will only work providing that your logon script declares the var $_SESSION['user_logged'] with a boolean value properly. If the user has logged, $_SESSION['user_logged'] = TRUE; else $_SESSION['user_logged'] = FALSE.
Check your logon script...
That first "if" statement will never be "false", so you may as well just code session_start();.
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
I took issue with checking isset($_SESSION) before the session_start() function was called (which seems to be what the OP is getting hung up on), that's all
and if you "just use session_start()", you'll cause another error if it has already been called in an include; hence it's safer to call session_start() after the test for $_SESSION being set. Best to provide solutions that wont introduce new errors.