Help me with php session.
I have php 5.5.21 on my server.
I have users and administrators.
I save user sessions in the session directory by default, but administrators to another (to provide longer service life).
My problem is that I cannot store the session for the administrator in another directory, and it dies faster than I need.
<?php
function isAdmin()
{
return true;
}
$path = session_save_path();
if (isAdmin()) {
$ttl = 36000;
$path .= '/sessionAdmin';
} else {
$ttl = 1440;
$path .= '/session';
}
session_save_path($path);
ini_set('session.gc_maxlifetime', $ttl);
ini_set('session.cache_expire', $ttl);
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 1);
session_start();
In addition, I added these directories to open_basedir '/var/www/vhosts/site.com:/usr/share/pear:/var/lib/php5/session:/var/lib/php5/sessionAdmin'
but this does not help me, and all new sessions are /var/lib/php5
not stored in the directory on /var/lib/php5/sessionAdmin.
source
share