Zend Framework Session Lost

I use sessions to store items in a shopping cart. I can create and save sessions, but with some strange problems:

  • When i close the tab in Firefox (not the entire browser), the session seems to have been lost. Sometimes this does not happen, but usually it happens.

  • Each time I refresh a page or go to another page, the session ID changes to a new one. I confirmed this by viewing the cookie with my browser as well as on the server. In addition, a maximum of 4 sessions are stored on the server at a time. Is this all normal behavior?

  • Sessions seem to be lost at random intervals ... it can be several minutes or more than an hour.

I just followed the Zend manual, but failed to resolve this. In bootstrap, I also have Session :: start () and Session :: rememberMe (). I use the usual file storage for sessions, just storing in / var / lib / php 5, which I think is like the way he likes the Zend Framework.

Thanks for any direction

+3
source share
3 answers

Check garbage cleaning time for PHP session.gc_maxlifetime. If it is short, it removes the session files from under your nose and makes it "random."

The default value is 24 minutes (1440 seconds).

This must be set (or more), regardless of how long your cookie ( session.cookie_lifetime) has been set in your application.

0
0

, - , , Bootstrap.php

    if (!empty($_REQUEST['PHPSESSID'])) {
        Zend_Session::setId($_REQUEST['PHPSESSID']);
    }

    Zend_Session::start();

This should solve the problem. When a user has a session, he is usually transferred with each request.

0
source

Source: https://habr.com/ru/post/1780766/


All Articles