This question already has an answer here:
How would I set a php session? Here's my code , yet it should work when I require it on the logged in page it just redirects me to the login page (its not set)
<?php
$_SESSION['logged_in']==1;
header('Location: loggedin.php');
?>
</div>
Use =
to assign not ==
. Double equal is used to compare. Also use session_start();
top of your code. Example:
session_start();
$_SESSION['logged_in'] = 1;
header('Location: loggedin.php');
You use double equal to sign (==) while comparing 2 quantities. You've to use 1 equal sign to assign value.
It should be:
<?php
session_start();
$_SESSION['logged_in']=1;
header('Location: loggedin.php');
?>