received (I think ...) a very simple problem:
I want to establish a session inside a function. Simple situation:
I received a registration form. After highlighting the form, I call the "login" function, which checks whether the user has been authenticated. If yes, the session should be established.
Here is a very simple code:
session_start();
function login() {
$SESSION['login'] = true;
}
if (isset($_REQUEST['doLogin'])) {
login();
}
if ($SESSION['login'] === true) echo 'you are logged in';
But that does not work. What for? Many thanks!
source
share