I\'m using PHP 4.3.9, Apache/2.0.52
I\'m trying to get a login system working that registers DB values in a session where they\'re available once lo
...may I add to the other answers, that session_start() sometimes fails or weird stuff occurs if not placed at the very first beginning of the script. In your header script, try:
Instead of
<?php
ob_start();
session_start();
Put
<?php
session_start();
ob_start();
Try doing a
session_regenerate_id(true);
before the
session_write_close();
Also. The best way IMO to do a login script is this:
Let the login logic be handled within the mainpage the user is trying to access.
Then you wont have the trouble of session not saving just before a redirect
I don't see a session_start()
in your login script. If you aren't starting the session I don't think php will save any data you place in the $_SESSION
array. Also to be safe I'd explicitly place variables into the $_SESSION
array instead of just overwriting the whole thing with $_SESSION = mysql_fetch_array($result);
.
I was having a similar problem when I discovered this:
http://www.w3schools.com/php/php_sessions.asp
You HAVE TO put the session_start(); before ANY html tags