php-general | 2005051
Date: 05/14/05
- Next message: Rory Browne: "Re: [PHP] php works in IE not Firefox?"
- Previous message: emre: "Re: [PHP] changing php ini location"
- In reply to: Richard Lynch: "Re: [PHP] Finding current PHP sessions"
- Next in thread: Marek Kilimajer: "Re: [PHP] Finding current PHP sessions"
- Reply: Marek Kilimajer: "Re: [PHP] Finding current PHP sessions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Ok, I went with the solution you recommended, by the way of a "thank
you" to the list, here's the resulting function:
/**
* This function returns the IDs of the current PHP sessions.
* At this time, it only works with
* { <email protected> http://www.php.net/manual/en/ref.session.php#AEN129461}
* PHP session.save_handler='files'
*
* <email protected> Bogdan Stancescu
* <email protected> http://opensource.org/licenses/lgpl-license.php GNU Lesser
General Public License
*
* <email protected> mixed false on error or the indexed array of the session IDs;
* please note that the session IDs are 16-bit values represented as
* 32-character long hexadecimal strings; letters are in lower caps.
*/
function getCurrentSessionIDs()
{
if (ini_get('session.save_handler')!='files') {
// sorry, we only know how to handle files at this time!
return(false);
}
$sessions=array();
$session_path=session_save_path();
$d = dir($session_path);
while (false !== ($entry = $d->read())) {
if (
($entry=='.') ||
($entry=='..') ||
(!is_file("$session_path/$entry"))
) {
continue;
}
if (preg_match("/^sess_([0-9a-f]{32})$/",$entry,$matches)) {
$sessions[]=$matches[1];
}
}
return($sessions);
}
Cheers,
Bogdan
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Rory Browne: "Re: [PHP] php works in IE not Firefox?"
- Previous message: emre: "Re: [PHP] changing php ini location"
- In reply to: Richard Lynch: "Re: [PHP] Finding current PHP sessions"
- Next in thread: Marek Kilimajer: "Re: [PHP] Finding current PHP sessions"
- Reply: Marek Kilimajer: "Re: [PHP] Finding current PHP sessions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

