Tuesday, 15 January 2013

PHP session lost after redirect -


How do I resolve the problem of losing a session after redirection in PHP?

Recently, I faced a very common problem of losing the session after redirection, and even after searching through this website, I can not find any solution (although it came closest)

Update

I got the answer and I thought I would post it here to help anyone in facing this same problem. Firstly, check these general:

Firstly, check this general:

  1. session_start (); is called before any session, then the opening & lt ;? Immediately after the Php tag, a safe bet will be placed at the beginning of your page, also ensure that the opening tag.
  2. header after redirection, exit ; (Other people have suggested that session_write_close (); and session_regenerate_id (true) , you can also try them, but I exit ();
  3. Make sure cookies are enabled in browsers used in browsers.
  4. Make sure register_globals is closed, you can call it Php.ini file and you can use phpinfo () .
  5. Make sure that you have not deleted or emptied the session
  6. Ensure the key in your $ _ session / supergobal array is not overwritten anywhere
  7. Make sure that you redirect to the same domain So do not forward the session from www.yourdomain.com to yourdomain.com .
  8. Make sure your file extension is .php (this happens!)

    Now, these are the most common mistakes, but if they do not move, then all of the problem Sector is more likely that your hosting company if everything Sthaniyhost works, but is not on your remote / testing server, it is likely to be the most criminal. So check the knowledge base of your hosting provider (try your forums etc). For companies like Faster and IPA, they need to specify session_save_path if you want to:

      session_save_path ('"your home directory path" / cgi- Bin / tmp '); Session_start ();   

    (replace your home directory path with your home's main directory path. This is usually within your control panel (or equivalent), but you have a test .php can also create file on your root directory and type:

        

    Before 'Test.php' the bit is your home directory path and of course make sure that the folder is actually present in your root directory. (Some Pro Gram does not upload empty folder when synchronizing)

No comments:

Post a Comment