Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8007411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:49:06+00:00 2026-06-04T17:49:06+00:00

I got stuck in a $_SESSION problem, while $_SESSION is randomly losing its data.

  • 0

I got stuck in a $_SESSION problem, while $_SESSION is randomly losing its data.

I have a form with different pages and the user has a specific amount of time to get through all pages.

So I set a session variable on the first page and check it on the others.

start.php

 <?php
    session_start();  

    //Set Variable for Starting application
    if (!isset($_SESSION['STARTED'])){
        $_SESSION['STARTED'] = time();
    }

app_init.php

<?php
session_start();

if ((!isset($_SESSION['STARTED'])) || (time() - $_SESSION['STARTED'] > MAX_TIMELIMIT)) {
    echo '<!-- st: '.$_SESSION['STARTED'].'-->';
    // Started Variable is not set or timelimit is over.
    session_destroy();   // destroy session data in storage
    session_unset();     // unset $_SESSION variable for the runtime
    showTimeout('0');   //  show timeout
}

Start of the pages afterwards:

<?php

// get basic settings for applications 
require_once (MODEL_PATH.'/app_init.php');

The whole system works very fine on local installation, Developmentserver and Testserver. On Productionserver I get a timeout at different times. It differs from 30 seconds to 10 minutes. MAX_TIMELIMIT is 20 minutes. $_SESSION['STARTED'] is always empty in that case. On the other environments it is correctly set, even if the timeout shows up after the 20 minutes.

Additonal info:

  • It doesn’t matter if I try to reach the next page or if I simply reload the actual page, I always get the timeout.
  • I already checked php.ini on any environment -> session.save_path is correctly set, session.cookie_lifetime is 0 and session.gc_maxlifetime is 1440
  • Diskspace is fine (> 22 GB free)
  • Every File is on the same server and has the same url (except the last part wich specifies the step of the form. Looks like this:
    host/some/path/calc -> host/some/path/form -> host/some/path/summary -> host/some/path/send
  • The session is set on the calc page and the timeout can happen on every page (calc, form, summary)
  • I got the php.ini from production server and took it into my local workspace. After changing some paths (extensions-path, session.save_path, tmp-path) it worked very well on my local installation.
  • Protocol is an all pages the same
  • To recreate the session (via $tmp and session_destroy(), session_create()) did not help
  • Single Frontend, no Loadbalancer (simply one apache)
  • Session Files are deleted somehow

After adding some outputs and retesting, I get the following:

  • I load the Page (first step)
  • I go through the form to any step (calc / form / summary)
  • when the page is loaded $_SESSION is

    array (
    'STARTED' => 1338298801,
    'S_SID_' => '41554681145546',
    'S_LC_' => 'de',
    'version_testing' => 1,
    )

  • I reload that page every thirty seconds

  • at least after 3 minutes (could also be 30 seconds) I get the timeout and $_SESSION is:

    array (
    )

  • if I try this on the first page, i get a new value in $_SESSION, as the sessiondata is empty and automaticly new set.

  • to Remember: On Test / Dev Environment, the sessiondata is still there, even the timeout occurs after 20 minutes.

  • changing session.save_path first seemed to work (sessions last at least 24 minutes). But after one hour, still the same problem. No session lasts more then 4 minutes.

Problem found (but no solution yet)
Today I got Access to Production-Server and I found out, the folder with Session-Data is cleaned up after 3-5 minutes. No file there has a timestamp older than 3 minutes.
As mentioned before, PHP is correctly set (GC lifetime), and I didnt found any windows job, or something similar what is deleting these files. As PHP.ini is set correctly, I’ll try to handle the session via database.

Thanks for help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:49:07+00:00Added an answer on June 4, 2026 at 5:49 pm

    What worked in this specific situation:

    Another website was hostet on the same server but in a different virtual host. This website used an “init.php” which was called on every request. It contained a line which set the gc_maxlifetime to 0 and started a session afterwards. So randomly at some request all sessiondata was cleared by that second website.

    On Test and Dev it was not a problem, as these two environments are not that much used…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got stuck with this problem. I wrap two tables inside of a h:form.
I am working on a problem and got stuck at a wall I have
I have the follow problem. This is the situation i've got when user login
I got stuck with a performance problem while writing my program and I need
I got stuck among the weared behaviour of browsers. Ihave a div which has
I got stuck in this problem for an hour. I am thinking this is
I've got stuck in a problem with gflags when trying to find some memory
I have a problem selecting 6 random friends This is the query I've got
I got stuck, my objective was to get the ProductID, hidden inside the $_SESSION['cart']
I got stuck in here, I have a custom scrollview in a view this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.