I want to end everyone's session in a particular time, suppose right now. In detail, I want everybody's session (including who is currently visiting my website) to be ended and they will need to log in again to see the website contents. How can this be done with php?
Asked
Active
Viewed 69 times
1 Answers
0
You could simply clear the session storage location you're using. For example, assuming you have session.save_handler
set to file
, you could do delete all files in session.save_path
. If you're using memcached, just delete the memcached keys with the associated session prefix.
Using file save handler
foreach(glob(ini_set("session.save_path") . "/*") as $sessionFile) {
unlink($sessionFile);
}
Using memcached save handler
$memcached = new Memcached;
$memcached->addServers($listOfYourMemcachedSesssionServers);
$sessionKeys = preg_grep("@^memc\.sess\.key\.@", $memcached->getAllKeys());
$memcached->deleteMulti($sessionKeys);

Sherif
- 11,786
- 3
- 32
- 57