Check by id, if the session exists, without extending the session

I work at the RIA. We use Memcached to store the sessions, and I installed http://pecl.php.net/package/memcache , and my PHP session handler looks like this:

$session_save_path = "tcp://$host:$port?persistent=1&weight=2&timeout=2&retry_interval=10,  ,tcp://$host:$port  ";
ini_set('session.save_handler', 'memcache');
ini_set('session.save_path', $session_save_path);

The session timeout is set to 30 minutes. In my RIA, I want to periodically access the script server through AJAX to check if the visitor session is alive. If ajax calls return false, I am disconnected from the screen and will show you pretty relogbox to continue the session.

Now the problem is with the script server. I need to determine if a session exists without increasing the session lifetime, if one exists.

I do not fully understand the work of the session handler, but I'm sure I will do this:

<?
session_start();
if($_SESSION['loggedin'] == "yes")
    echo "true";
else 
    echo "false";
?>

, ( , , cookie ). .

, , :

  • , javascript (, 30 ). , RIA .
  • session_start(), cookie . , - session_handling.

, T.i.a.

+3
2

- . , , . , , . , , , , .

- :

$acl->logIn($username); //set the user as logged in
$acl->isLoggedIn($username); //Is he still logged in?

..

+1

Javascript. .

Ajax $_SESSION ['loggedin'] - , , $_SESSION ['loggedin'] .

0

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


All Articles