Beispiel #1
0
echo "Total active sessions: " . msession_count() . "<br>\n";

# This gets all the variables for a user in an associative array.
$varray = msession_get_array($sid);

if(!$varray)
	echo "Get variable array: Failed<br>\n";

# Display all the user's variables
$arraykeys = array_keys($varray);
for($i=0; $arraykeys[$i]; $i++)
	echo "Key: " . $arraykeys[ $i ] ." = " .$varray[$arraykeys[$i]] ."<br>\n";

	
# Find a list of all sessions with same name/value pair
$array = msession_find('name1', 'test1');

#display the sessions
for($i=0; $array[$i]; $i++)
	echo "Similar Sessions: " . $i . " " . $array[$i] . "<br>\n";

# Find all the sessions which have the variable "time" set.
$vararray = msession_listvar('time');

$arraykeys = array_keys($vararray);

for($i=0; $arraykeys[$i]; $i++)
	echo "Key: " . $arraykeys[ $i ] ." = " .$vararray[$arraykeys[$i]] ."<br>\n";

# msession can support a personality plugin, this is an escape call directly
# into the plugin's REQ_ESCAPE function.
Beispiel #2
0
 /**
  * Deletes all expired files.
  *
  * Note: garbage collection should cause lot's of network traffic.
  *
  * @param    integer Maximum lifetime in seconds of an no longer used/touched entry
  * @throws   Cache_Error
  */
 function garbageCollection($maxlifetime)
 {
     $this->flushPreload();
     $sessions = msession_find('_pear_cache', true);
     if (empty($sessions)) {
         return true;
     }
     $total = 0;
     $entries = array();
     foreach ($sessions as $k => $id) {
         $data = msession_get($id, '_pear_cache_data', NULL);
         if (NULL == $data) {
             continue;
         }
         if ($data['expires'] <= time()) {
             msession_destroy($id);
             continue;
         }
         $size = msession_get($id, '_pear_cache_size', NULL);
         $total += $size;
         $entries[$data['expires']] = array($id, $size);
     }
     if ($total > $this->highwater) {
         krsort($entries);
         reset($entries);
         while ($total > $this->lowwater && (list($expires, $entry) = each($entries))) {
             msession_destroy($entry[0]);
             $total -= $entry[1];
         }
     }
     return true;
 }