Jump to content

I Have a question


Tom8001

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
https://forums.phpfreaks.com/topic/292685-i-have-a-question/
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
https://forums.phpfreaks.com/topic/292685-i-have-a-question/#findComment-1497527
Share on other sites

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.