php - Losing session variables after redirect -


  1. User fills in user name and password.
  2. If this is true, then the page loads some information such as user_id in a session variable.
  3. The script redirects a header ('location') .
  4. Somehow do not recognize next page session ... how come?

Redirection is for the same domain, and all pages have session_start ();

And I found it more likely to be in IE compared to FF ...

Is it possible that cookies are not enabled?

To be able to add session variables with a specific client example (ie session variables can be used on your browser and on my browser, do not come in a conflict time), a "session ID "(or" SID ") is generated per session. This ID is stored on the server as well as on the client, usually as a cookie. However, if cookies are not enabled, session IDs are passed in each request as part of the URL's query string so that the server knows that the session ID is related to the client.

When you redirect, by the header () call, PHP does not automatically include the SID in the new request, so you have to attach it as yourself:

  header ("location: my_url.com/my_page.php?" .sid)  

where PHP is a constant defined in which query string is required The part is ( Session_name (). '='. Session_id () , if session ID is present).

See for more information.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -