Example #1
0
 /**
  * Change session type.
  *
  * @param integer $type	Default if not otherwise specified
  * @param integer $duration	In minutes, required only for extended
  */
 public static function change_type($type = null, $duration = null)
 {
     global $session_type;
     if (is_null($type)) {
         $type = $session_type;
     }
     // calculate duration based on type
     switch ($type) {
         case Session::TYPE_EXTENDED:
             if (is_null($duration)) {
                 $duration = 30 * 24 * 60;
             }
             $timestamp = time() + $duration * 60;
             break;
         case Session::TYPE_BROWSER:
             $timestamp = 0;
             break;
         case Session::TYPE_NORMAL:
         default:
             $timestamp = time() + Session::DEFAULT_DURATION * 60;
             break;
     }
     // modify cookies
     setcookie(Session::COOKIE_ID, session_id(), $timestamp, Session::get_path());
     setcookie(Session::COOKIE_TYPE, $type, $timestamp, Session::get_path());
 }