skip to Main Content

I’m using session variables in my php application, and I put session_start() at the first line (after the php, of course) of all my pages. But I’m losing data from two pages before.

Example: If I store $_SESSION['var1'], in the next page I will retrieve its value correctly, but if I go one more page ahead, I lose the data.

I use session_start() in all pages and I only reset the session at the index page where my user login-in.

Did someone pass through this and know what can I do? I’m testing using wamp, and in the localhost the problem doesn’t happen. It only happens at my company’s godaddy server (with cpanel hosting).

2

Answers


  1. Chosen as BEST ANSWER

    Solved.
    My index.php was destroying the session data, even if the page doesn't pass trhought it, the session was always erased.


  2. This is just a comment
    Its the problem of the server and not the script. Usually to maintain the server load the sessions that are created at your site can expire in a short amount of time. There are ways like editing the php.ini file of the www directory but every hosting server could have different methods.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search