darksniperx Posted August 2, 2011 Share Posted August 2, 2011 I have a header.php which is included to all php files. Header.php has the following: <?php session_start(); if(isset($_SESSION)|| $_SESSION != null){ if(isset($_SESSION['message'])){ echo '<br />Login status: '. $_SESSION['message'] ; } } ?> I have a login.php which has header.php included. <?php include header.php ...code if($validate){$_SESSION['message'] = 'Validated';} else{$_SESSION['message'] = 'Unautorized';} ?> when i refresh the page after submit , and check for $_SESSION['message'] it is always empty. same thing is i created another php page, included header.php, and when i redirect to it after login.php the session variable is still empty? Cant figure out why. Link to comment https://forums.phpfreaks.com/topic/243541-having-big-issues-with-session-variables/ Share on other sites More sharing options...
btherl Posted August 2, 2011 Share Posted August 2, 2011 Can you try a simpler version of your login.php, which simply includes header.php, sets $_SESSION='message' = 'test' and then exits immediately. That will either conrfirm that sessions are working, or determine that they are not working. Link to comment https://forums.phpfreaks.com/topic/243541-having-big-issues-with-session-variables/#findComment-1250539 Share on other sites More sharing options...
darksniperx Posted August 2, 2011 Author Share Posted August 2, 2011 I figured out the issue somewhat. I am using and mvc design. And when i research it, i found out that i either need to make a library to handle session variables or use cookies. Since i used the code for mvc of tutorial on build your own mvc that i found on some site, its pretty bugged. When i tried cookies, they seem to work, but i will test them out more concretely tomorrow. Link to comment https://forums.phpfreaks.com/topic/243541-having-big-issues-with-session-variables/#findComment-1250541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.