Esempio n. 1
0
 /**
  * Checks to see if their session is still valid in memcache
  * @param
  *      $session_id: The ID of the session we want to check
  * @return
  *      An error string if memcache fails
  *      A user ID if we find their session
  *      A null if we don't find their session
  */
 function check_session($session_id)
 {
     // If this person is logged in
     $user_id = memcached::get('medusa_sessionid_' . $session_id);
     if (is_numeric($user_id)) {
         // Refresh their session - if it fails, report it
         if (!memcached::set('medusa_sessionid_' . $session_id, $user_id)) {
             return 'Memcache Error: ' . memcached::report_last_error() . ' (memcached::set)';
         }
         // Login still valid, tell them who the user is
         return $user_id;
     } else {
         // Login isn't valid, tell them we aren't a user
         return null;
     }
 }