I am stuck in a problem $_SESSIONand $_SESSIONaccidentally lost my data.
I have a form with different pages, and the user has a certain amount of time to go through all the pages.
Therefore, I set the session variable on the first page and check it on others.
start.php
<?php
session_start();
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
}
Beginning of pages:
<?php
require_once (MODEL_PATH.'/app_init.php');
The whole system works very well on a local installation, Developmentserver and Testserver. On the Productionserver, I get a timeout at different times. It differs from 30 seconds to 10 minutes. MAX_TIMELIMITis 20 minutes. $_SESSION['STARTED']always empty in this case. In other environments, it is set correctly, even if a timeout appears after 20 minutes.
Additional Information:
- , , -.
php.ini → session.save_path , session.cookie_lifetime 0 session.gc_maxlifetime 1440- ( > 22 )
- URL- ( , .
host/some/path/calc → host/some/path/form → host/some/path/summary → host/some/path/send
- calc, (calc, form, summary)
- php.ini . (extensions-path, session.save_path, tmp-path) .
- -
- (
$tmp session_destroy(), session_create()) - Single Frontend, Loadbalancer ( apache)
- -
:
- ( )
- (calc/form/summary)
$_SESSION -
array (
'STARTED' => 1338298801,
'S_SID_' => '41554681145546',
'S_LC_' => 'de',
'version_testing' => 1,
)
3 ( 30 ) $_SESSION:
array (
)
, $_SESSION, session .
: Test/Dev , 20 .
session.save_path ( 24 ). , . 4 .
( )
Access to Production-Server, , Session-Data 3-5 . 3 .
, PHP ( GC), - , . PHP.ini , .