Jump to content

I Have a question


Tom8001
Go to solution Solved by Ch0cu3r,

Recommended Posts

On my login page i have a set a session when the user logs in called loggedIn and it = true

if($count == 1) {

		$_SESSION['username'];
		$_SESSION['password'];
		$_SESSION['loggedIn'] = true;
		header("Location: index.php");

and on my index page i have 

session_start();

if(!isset($_SESSION['loggedIn'])) {

	echo "You are not currently logged in and to view this page you must be logged in to have access.";
	die();
}

but when the user logs in it comes up with the message above echo "You are not currently logged in and to view this page you must be logged in to have access."; which obviously it should not do.

 

Does anyone know how i can fix this?

Link to comment
Share on other sites

 

 

'm kinda new to PHP what does session_write_close(); mean?

 

It will write the data currently stored in the session to disk. This is done automatically when PHP reaches the end of the script.

 

If  you ever come across functions you don't know then always look at their documentation at php.net.

 

TIP: You can type any function name after php.net/ to see their documentation. Example urls

php.net/session_write_close

php.net/session_start

 

 

 

it logged in and said 

So data is being saved. Then you should not be getting the "You are not currently logged in ..." message?

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.