tags:

views:

57

answers:

1

hi there,

got a (I guess...) very simple problem:

I want to set a session within a function. Simple situation:

I got a login form. After subimitting the form, I call a function "login" which checks if user has authenticated. If yes, a session should be set.

Here some very simple code:

session_start();

function login() {
  $SESSION['login'] = true;
}

if (isset($_REQUEST['doLogin'])) {
  login();
  // is session is set here, it works...
}

if ($SESSION['login'] === true) echo 'you are logged in';

But this doesn't work. Why? Thanks alot!

+12  A: 

You are using $SESSION you need to be using $_SESSION

Brad F Jacobs
Uh damn I'm really embarrassed. Haven't coded php for month and obvisously I've lost my eye for it. thank you and sorry this superfluous "question" ;)
ben
It happens to the best of us :)
Brad F Jacobs