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.

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.