Jump to content

Having big issues with session variables!


darksniperx

Recommended Posts

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.

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.