Forum Moderators: coopster
I used the following to set the cookie
setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path, $cookie_domain, $cookie_secure); The fist value is I guess the session_id given by the server and the second value is an array (user_id, encrypted password, expiration time, path, domain, secure).
Everytime a page is called, I decrypt the password and check that password and user_id match. If not, I reset the cookie as "Guest".
Everything works fine.
*****************************
Then, I have the SESSION where I store few extra infos.
Everything works great except for the example below.
I have advance forms where users can upload pictures for example and I use HTTP_REFERER to a URL in the session to show a friendly "back to the page you came from" link after the form is submitted.
if(isset($_SERVER["HTTP_REFERER"])) {$_SESSION['back_url']=$_SERVER["HTTP_REFERER"];} And it doesn't work. I can not see the back_url in the session, neither in the cookie... But it exists since $_SESSION['back_url'] give me the link.
I can only guess that the problem is related to the cookie since it was working perfectly before cookie was implemented. Anything wrong?
Thank you
And it doesn't work. I can not see the back_url in the session, neither in the cookie... But it exists since $_SESSION['back_url'] give me the link.
I'm not exactly sure what your issue is here. Are you sure that you used session_start [us2.php.net] before you tried to set the session variable?
Also, adding error_reporting(E_ALL); [us2.php.net] to the top of the script will help identify any hidden errors.
Yes, I used session_start() before working/checking cookie; and no hidden errors!
But I have added ob_start() at the beginning of my login/logout/register (the ones sending cookies) to remove the "Cannot modify header information" error. I was getting this error despite the fact that cookie is sent before any HTML output (neither blank space).
I hope that I am not confusing everyone with all my assumptions. To make it short, the problem is that I have difficulties to set data in $_SESSION.