Reputation:
I have been working on this for awhile and can't seem to pin it down. Sessions are working I have session_start() at the top of each page that I access or set sessions.
First off I started with three sessions variables $_SESSION['id'], $_SESSION['user'] and $_SESSION['start'] to my login script and everything was working fine. I added two more sessions $_SESSION['patron'] and $_SESSION['business'].
$_SESSION['user'] = $user_info['email'];
$_SESSION['id'] = $user_info['id'];
$_SESSION['patron'] = $user_info['patron'];
$_SESSION['business'] = $user_info['business'];
$_SESSION['start'] = time();
redirect_to('../page.php');
All sessions are set after login script is run and redirected fine, but I lose some of them when I redirect again leaving just the $_SESSION['user'], $_SESSION['start'] and $_SESSION['id'] sessions still set. I don't understand why only some are still set and the others are lost.
Another issue is that I changed the session $_SESSION['start'] name to $_SESSION['time'] and now that session is lost when I redirect after my login script has run.
Here is my redirect script:
function redirect_to($location = NULL) {
if($location != NULL) {
define('URL', 'http://www.website.com/');
header('Location: ' .URL. $location);
exit();
}
}
Any suggestions will be appreciated.
Upvotes: 0
Views: 188
Reputation:
SOLVED!!!
I've been working on this project for too long...I forgot that I had a function that purges sessions. It unsets sessions created by form submissions. I have an array that has session names to ignore and I left these out of it. So every time a page is refreshed, it unsets those sessions. I am so sorry for wasting your time. I completely forgot about it. I worked on that for about two hours....Lame.
Upvotes: 0