当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::exists方法代码示例

本文整理汇总了PHP中Session::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::exists方法的具体用法?PHP Session::exists怎么用?PHP Session::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Session的用法示例。


在下文中一共展示了Session::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __isset

 /**
  * Determines whether a variable in this session section is set.
  * @param  string    name
  * @return bool
  */
 public function __isset($name)
 {
     if ($this->session->exists()) {
         $this->start();
     }
     return isset($this->data[$name]);
 }
开发者ID:riskatlas,项目名称:micka,代码行数:12,代码来源:SessionSection.php

示例2: __construct

 public function __construct($user = null)
 {
     $this->_db = DB::getInstance();
     $this->session_name = Config::get('session/session_name');
     $this->_cookieName = Config::get('remember/cookie_name');
     if (!$user) {
         if (Session::exists($this->session_name)) {
             if ($this->find_by_id(Session::get($this->session_name))) {
                 $this->_isLoggedIn = true;
             } else {
                 // logout process
                 $this->logout();
             }
         } elseif (Cookie::exists($this->_cookieName)) {
             $this->_db->get('user_id', 'users_session', array('hash', '=', Cookie::get($this->_cookieName)));
             if ($this->find_by_id($this->_db->first()->user_id)) {
                 Session::put($this->session_name, $this->data()->id);
                 Cookie::put($this->_cookieName, Cookie::get($this->_cookieName), Config::get('remember/cookie_expiry'));
                 Session::flash('success', 'Wellcome Back ' . $this->data()->username);
                 $this->_isLoggedIn = true;
             } else {
                 $this->logout();
             }
         }
     } elseif (is_numeric($user)) {
         if ($this->find_by_id($user)) {
             Session::put($this->session_name, $this->data()->id);
             $this->_isLoggedIn = true;
         } else {
             $this->logout();
         }
     } elseif (is_string($user)) {
         return $this->find($user);
     }
 }
开发者ID:shaheen13,项目名称:origin,代码行数:35,代码来源:User.php

示例3: __construct

 public function __construct($user = null)
 {
     $this->_db = DB::getInstance();
     $this->_sessionName = Config::get('session/session_name');
     $this->_cookieName = Config::get('remember/cookie_name');
     $this->_admSessionName = Config::get('session/admin_name');
     if (!$user) {
         if (Session::exists($this->_sessionName)) {
             $user = Session::get($this->_sessionName);
             if ($this->find($user)) {
                 $this->_isLoggedIn = true;
             } else {
                 // process logout
             }
         }
         if (Session::exists($this->_admSessionName)) {
             $user = Session::get($this->_admSessionName);
             if ($this->find($user)) {
                 $this->_isAdmLoggedIn = true;
             } else {
                 // process logout
             }
         }
     } else {
         $this->find($user);
     }
 }
开发者ID:NamelessMC,项目名称:Nameless,代码行数:27,代码来源:User.php

示例4: get

 public static function get($key)
 {
     $prefixkey = self::$prefix . $key;
     if (Session::exists($prefixkey)) {
         return Session::get($prefixkey);
     }
 }
开发者ID:Kocal,项目名称:Loytonia-webchat,代码行数:7,代码来源:Auth.php

示例5: Create

 public static function Create($p_sessionId, &$p_objectId, $p_objectTypeId = null, $p_userId = null, $p_updateStats = false)
 {
     if (empty($p_sessionId)) {
         throw new SessionIdNotSet();
     }
     $session = new Session($p_sessionId);
     if (!$session->exists()) {
         $sessionParams = array('start_time' => strftime("%Y-%m-%d %T"));
         if (!empty($p_userId)) {
             $sessionParams['user_id'] = $p_userId;
         }
         $session->create($sessionParams);
     }
     $sessionUserId = $session->getUserId();
     if (!empty($p_userId) && !empty($sessionUserId) && $sessionUserId != $p_userId) {
         throw new InvalidUserId();
     }
     $requestObject = new RequestObject($p_objectId);
     if (!$requestObject->exists()) {
         if (empty($p_objectTypeId)) {
             throw new ObjectTypeIdNotSet();
         }
         $requestObject->create(array('object_type_id' => $p_objectTypeId));
         $p_objectId = $requestObject->getObjectId();
     } elseif (empty($p_objectId)) {
         throw new ObjectIdNotSet();
     }
     if ($p_updateStats) {
         self::UpdateStats($p_sessionId, $p_objectId);
     }
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:31,代码来源:SessionRequest.php

示例6: authorize_user

 /**
  * Si no existe una sesion para el usuario dado, se le redirecciona a la vista de login para que puedan iniciar sesion.
  */
 public function authorize_user()
 {
     if (!Session::exists($_COOKIE['user_id'])) {
         header("Location: " . APP_PREFIX . "/sessions/login");
         exit(0);
     }
 }
开发者ID:santiagodoldan,项目名称:electiva_php_ude_2015,代码行数:10,代码来源:application_controller.php

示例7: startNewSession

 public function startNewSession()
 {
     if (!loggedIn() && (privilege() != 'dean' || privilege() != 'director' || privilege() != 'admin')) {
         return 0;
     }
     $this->_connect();
     if (!Session::exists('semester_session')) {
         $type = 'odd';
         $session = date('Y');
     } else {
         if (Session::get('semester_type') === 'even') {
             $type = 'odd';
             $session = Session::get('semester_session');
         } else {
             if (Session::get('semester_type') === 'odd') {
                 $type = 'even';
                 $session = Session::get('semester_session') + 1;
             }
         }
     }
     $timestamp = date('Y-m-d H:i:s');
     $query = "INSERT INTO semester_session (session,type,starting_timestamp) VALUES('" . $session . "','" . $type . "','" . $timestamp . "')";
     $result = $this->_db->query($query);
     if ($this->_db->affected_rows && $this->_db->error == '') {
         $this->getRunningSession();
         return 1;
     } else {
         return 0;
     }
 }
开发者ID:mkrdip,项目名称:Management-Information-System,代码行数:30,代码来源:Semester.php

示例8: httpRedirect

 /**
  * Perform HTTP redirect with saving POST params in session.
  *
  * @param string $url URL redirect to.
  * @param array<mixed> $postData List of post params to save.
  */
 public static function httpRedirect($url = "", $postData = [])
 {
     if (preg_match("#^http[s]?://.+#", $url)) {
         // absolute url
         if (function_exists("http_redirect")) {
             http_redirect($url);
         } else {
             self::http_redirect($url);
         }
     } else {
         // same domain (relative url)
         if (!empty($postData)) {
             if (is_array($postData)) {
                 if (!Session::exists('_post') || !is_array($_SESSION['_post'])) {
                     Session::set('_post', []);
                 }
                 foreach ($postData as $fieldName => $fieldValue) {
                     Session::set("_post[{$fieldName}]", serialize($fieldValue));
                 }
             } else {
                 throw new HttpException("Wrong POST data.");
             }
         }
         if (function_exists("http_redirect")) {
             http_redirect("http://" . $_SERVER['SERVER_NAME'] . "/" . $url);
         } else {
             self::http_redirect("http://" . $_SERVER['SERVER_NAME'] . "/" . $url);
         }
     }
 }
开发者ID:asymptix,项目名称:framework,代码行数:36,代码来源:Http.php

示例9: __construct

 public function __construct($user = null)
 {
     $this->_db = DB::getInstance();
     //get instance of DB
     $this->_sessionName = Config::get('session/session_name');
     //get default session array name
     $this->_cookieName = Config::get('remember/cookie_name');
     //get default remember cookie name
     if (!$user) {
         //if user is not set
         if (Session::exists($this->_sessionName)) {
             //if the default session exists
             $user = Session::get($this->_sessionName);
             //set user (id) to the value of default session
             if ($this->find($user)) {
                 //find the user with this id
                 $this->_isLoggedIn = true;
                 //set private variable isLoggedIn to true
             } else {
                 $this->logout();
                 //if not, log out
             }
         }
     } else {
         $this->find($user);
         //if user is set, find user
     }
 }
开发者ID:rafalstapinski,项目名称:rps,代码行数:28,代码来源:User.php

示例10: _index

 public function _index()
 {
     $post = Input::post();
     if (!empty($post)) {
         $validate = Validate::register($post);
         $token = Token::check($post['token']);
         if ($validate === TRUE && $token === TRUE) {
             User::addUser($post);
             echo 'Registered';
         } else {
             if (!$token) {
                 echo 'Security Token is missing';
             }
             echo '<pre>';
             print_r($validate);
             echo '</pre>';
         }
     } else {
         if (Session::exists('user_id')) {
             header('Location: /');
             exit;
         }
         self::init('RegisterModel', 'register', $arg);
     }
 }
开发者ID:ncube,项目名称:edu,代码行数:25,代码来源:register.php

示例11: getTracking

 private static function getTracking($offer_id = null, $params = null, $options = null)
 {
     if (!$offer_id) {
         $offer_id = self::getSelectedOfferId();
     }
     if (!$params && !$options && Session::exists('tracking')) {
         $tracking = Session::read('tracking');
         if ($tracking['offer_id'] == $offer_id) {
             return $tracking;
         }
     }
     $user = Session::read('User');
     $response = ApiClient_HasOffers_Request::Execute('Offer', 'generateTrackingLink', array('offer_id' => $offer_id, 'affiliate_id' => $user['affiliate_id'], 'params' => $params, 'options' => $options));
     $tracking = $response->getValue();
     /* Array ( 
     			'affiliate_id' => 1,
     			'offer_id' => 2,
     			'click_url' => "http://demo.go2jump.org/aff_c?offer_id=2&aff_id=1",
     			'impression_pixel' => "<img src="http://demo.stage-go2jump.org/aff_i?offer_id=2&amp;aff_id=1" width="1" height="1">"
     		) */
     if (!$params && !$options) {
         Session::write('tracking', $tracking);
     }
     return $tracking;
 }
开发者ID:MrYogi,项目名称:hasoffers-promotional-platform,代码行数:25,代码来源:Main.php

示例12: __construct

 public function __construct($user = NULL)
 {
     //get db instance
     $this->_db = DB::getInstance();
     //get session name, which is just 'user'. See init.php
     $this->_sessionName = Config::get('session/session_name');
     $this->_cookieName = Config::get('remember/cookie_name');
     if (!$user) {
         //if a user has NOT been defined
         if (Session::exists($this->_sessionName)) {
             $user = Session::get($this->_sessionName);
             //check if user exists
             if ($this->find($user)) {
                 //if there is a session and the user exists,
                 //signify they're logged in
                 $this->_isLoggedIn = true;
             } else {
                 //process logout
             }
         }
     } else {
         //if a user HAS been defined
         $this->find($user);
     }
     //end if
 }
开发者ID:CNguyenT,项目名称:LoginRegisterSystem,代码行数:26,代码来源:User.php

示例13: hasAlert

 public function hasAlert()
 {
     if (\Session::exists($this->getPageName() . 'Alert')) {
         return true;
     }
     return false;
 }
开发者ID:25564,项目名称:Resume,代码行数:7,代码来源:Model.php

示例14: get

 /**
  * Get the value of the variable session
  * @param $name string The name of variable in session
  * @return object Value of variable or null
  */
 public static function get($name)
 {
     if (Session::exists($name)) {
         return $_SESSION[$name];
     }
     return null;
 }
开发者ID:quenti77,项目名称:easyhq,代码行数:12,代码来源:Session.php

示例15: lookupIp

 /**
  * Will return location data given a user's ip address.
  * @param string $ip The ip address to backtrace.
  * @return array
  */
 public static function lookupIp($ip = null)
 {
     // Log whether the ip was null
     $wasNull = false;
     // Let's see if we've done this recently for this session
     if ($ip == null && Session::exists('backtrace_ip')) {
         return Session::get('backtrace_ip');
     }
     // Choose the ip to use
     if ($ip == null) {
         $wasNull = true;
         $ip = Session::getIpAddress();
     }
     // Format the host string for the api
     $host = sprintf(self::IP_BACKTRACE_HOST, $ip);
     // Get the response from the api
     $response = Utils::curl_get_contents($host);
     $data = unserialize($response);
     // Return the info in an array
     $result = array('ip' => $ip, 'city' => $data['geoplugin_city'], 'state' => $data['geoplugin_region'], 'state_full' => $data['geoplugin_regionName'], 'area_code' => $data['geoplugin_areaCode'], 'dma' => $data['geoplugin_dmaCode'], 'country_code' => $data['geoplugin_countryCode'], 'country_name' => $data['geoplugin_countryName'], 'continent_code' => $data['geoplugin_continentCode'], 'latitude' => $data['geoplugin_latitude'], 'longitude' => $data['geoplugin_longitude'], 'currency_code' => $data['geoplugin_currencyCode'], 'currency_symbol' => $data['geoplugin_currencySymbol']);
     // Now let's get the zip code
     $latLongLookup = self::lookupLatLong($result['latitude'], $result['longitude']);
     $result['zip'] = $latLongLookup['zip'];
     // Save this for future reference, if this was the current user's ip
     if ($wasNull) {
         Session::set('backtrace_ip', $result);
     }
     // Now let's return the result
     return $result;
 }
开发者ID:brandonfrancis,项目名称:scsapi,代码行数:35,代码来源:geolocation.php


注:本文中的Session::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。