Session will not remain redirected

Here is the code:

final public function login($email) {
    $this->email = mysql_real_escape_string($email);
    $this->q = "SELECT id FROM users WHERE mail = '$this->email'"; 
    $this->r = mysql_query($this->q);
    $this->id = mysql_result($this->r, 0);
    $_SESSION['id'] = "$this->id";

    header('Location: me.php');
    exit;
    }

I am not sure when I redirect the session, I do not stay. I repeated it on the current page and it showed. Any solutions? I have a global namespace, so the session is established in all files.

+3
source share
1 answer

Whenever you are dealing with sessions in PHP, you should use session_start()to load session data into memory.

Call session_start()only once per page.

0
source

All Articles