本文整理汇总了PHP中session_decode函数的典型用法代码示例。如果您正苦于以下问题:PHP session_decode函数的具体用法?PHP session_decode怎么用?PHP session_decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了session_decode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_user_id
/**
* This function returns the user ID of the logged in user on your site. Technical support will not
* help you with this for stand-alone installations. You must purchase the professional installation
* if you are having trouble.
*
* Suggestion: Check out the other integration files in the functions/integrations directory for
* many examples of how this can be done. The easiest way is to get the user ID through a cookie.
*
* @return the user ID of the logged in user or NULL if not logged in
*/
function get_user_id()
{
$userid = NULL;
/*session_name('CAKEPHP');
session_start();
if (isset($_SESSION['userid']))
{
$userid = $_SESSION['userid'];
}*/
if (isset($_COOKIE['CAKEPHP'])) {
global $db;
$result = $db->execute("\n\t\t\t\tSELECT `data` \n\t\t\t\tFROM `cake_sessions`\n\t\t\t\tWHERE `id` = '" . $_COOKIE['CAKEPHP'] . "'\n\t\t\t");
if ($result and $db->count_select() > 0) {
$row = $db->fetch_array($result);
$session_data = $row['data'];
session_start();
session_decode($session_data);
if (isset($_SESSION['userid'])) {
$userid = $_SESSION['userid'];
}
}
}
return $userid;
}
示例2: LoadSessionByToken
public function LoadSessionByToken($token)
{
$query = sprintf("SELECT sessionid, sessdata FROM [|PREFIX|]sessions WHERE sessionhash='%s'", $GLOBALS['ISC_CLASS_DB']->Quote($token));
$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
$session = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
return @session_decode($session['sessdata']);
}
示例3: buildFiles
public function buildFiles()
{
$ess_usronline = new ess_usronline();
$ess_usronline->query('DELETE FROM ess_usronline');
$datSesAct = session_encode();
$d = dir($session_path = session_save_path());
while (false !== ($entry = $d->read())) {
$session_file_name = $session_path . '/' . $entry;
if (is_readable($session_file_name)) {
if (is_file($session_file_name)) {
$arVarSes = array();
$filesize = filesize($session_file_name);
if ($filesize > 20) {
$_SESSION['datetime'] = $_SESSION['ip'] = $_SESSION['user_id'] = '';
$cont = '';
$f = fopen($session_file_name, 'r');
$cont = fread($f, $filesize);
fclose($f);
session_decode($cont);
if ($_SESSION['user_id'] != "") {
$ess_usronline->usuario_id = $_SESSION['user_id'];
$ess_usronline->ip = $_SESSION['ip'];
$ess_usronline->sesname = $entry;
$ess_usronline->size = intval($filesize / 1024);
$ess_usronline->filectime = date("Y-m-d H:i:s", filectime($session_file_name));
$ess_usronline->datetime = $_SESSION['datetime'];
$ess_usronline->save();
}
}
session_decode($datSesAct);
}
}
}
$d->close();
}
示例4: write
function write($sid, $data)
{
$time = time();
$login = date("Y-m-d H:i:s");
if ($data) {
$current = $_SESSION;
session_decode($data);
$data = $_SESSION["data"];
$data = $this->db->real_escape_string($data);
$_SESSION = $current;
}
$query = $this->db->query("SELECT data FROM session_holder WHERE id = '{$sid}'");
$existRow = $query->num_rows;
$name = $query->fetch_array();
if ($existRow > 0) {
if (empty($_POST["login"])) {
echo "<span class = 'logMsg'>Welcome back, " . $name[0] . "!</span>";
} else {
echo "<span class = 'err'>You have logged in already as " . $name[0] . ".</span>";
}
} else {
if (!empty($data)) {
$this->result = $this->db->query("INSERT INTO session_holder VALUES('{$sid}', '{$time}', '{$data}', '{$login}')") or die("Cannot login.");
echo "<span class = 'logMsg'>Log in successful. \n\t\t\t Session should last " . $this->maxlifetime / 60 . " minutes. \n\t\t\t See the new Log History here: <a href = " . $_SERVER['REQUEST_URI'] . "> View Log</a></span>";
}
}
return true;
}
示例5: write
/**
* Write the session data, convert to json before storing
* @param string $id The SESSID to save
* @param string $data The data to store, already serialized by PHP
* @return boolean True if memcached was able to write the session data
*/
public function write($id, $data)
{
$tmp = $_SESSION;
session_decode($data);
$new_data = $_SESSION;
$_SESSION = $tmp;
return $this->memcache->set("sessions/{$id}", json_encode($new_data), 0, $this->lifetime);
}
示例6: get
/**
* Get information on a session.
*
* @param string $id A session id.
*
* @return array The session variables.
*/
public function get($id)
{
$realSession = $_SESSION;
session_decode($this->redis->get(self::PREFIX . $id));
$userSession = $_SESSION;
$_SESSION = $realSession;
return $userSession;
}
示例7: read
/**
* {@inheritdoc}
*/
public function read($sessionId)
{
$sessionData = Cache::read($sessionId, Configure::read('Session.handler.config'));
session_decode($sessionData);
$restoredSessionData = $_SESSION;
foreach ($_SESSION as $key => $value) {
unset($_SESSION[$key]);
}
return serialize($restoredSessionData);
}
示例8: handleLogout
/**
* Delete sessions with given userId and deviceId.
*
* @see Rublon2FactorCallback::handleLogout()
*/
protected function handleLogout($userId, $deviceId)
{
foreach (glob(ini_get('session.save_path') . "/sess_*") as $file) {
$contents = @file_get_contents($file);
session_decode($contents);
if (!empty($_SESSION['user']) and !empty($_SESSION['user']['login']) and $_SESSION['user']['login'] == $userId and (empty($_SESSION['rublonDeviceId']) or $_SESSION['rublonDeviceId'] == $deviceId)) {
unlink($file);
}
}
}
示例9: write
/**
* Write the session data, convert to json before storing
* @param string $id The SESSID to save
* @param string $data The data to store, already serialized by PHP
* @return boolean True if redis was able to write the session data
*/
public function write($id, $data)
{
$tmp = $_SESSION;
session_decode($data);
$new_data = $_SESSION;
$_SESSION = $tmp;
$this->redis->set("sessions/{$id}", json_encode($new_data));
$this->redis->expire("sessions/{$id}", $this->lifetime);
return true;
}
示例10: ms_read
function ms_read($sessid)
{
$result = executeQuery("SELECT * FROM currentsession WHERE sessionID='{$sessid}'");
if ($row = $result->firstrow()) {
session_decode($row["variables"]);
return TRUE;
} else {
return FALSE;
}
}
示例11: write
/**
* Writes Session json_encoded, so we can access the Session data with other clients like node.js
*/
public function write($id, $data)
{
$tmp = $_SESSION;
session_decode($data);
$new_data = $_SESSION;
$_SESSION = $tmp;
$id = $this->redisKeyPath() . $id;
$this->client->set($id, json_encode($new_data));
$this->client->expire($id, $this->ttl);
return true;
}
示例12: testGetPDOSession
public function testGetPDOSession()
{
$session = new \Reservat\Session\Session($this->di, 'PDO');
session_id('k4o6898jdru8e8gah9mkv5fss5');
//session_decode($this->sessionData);
$handler = $session->getHandler();
session_decode($handler->read('k4o6898jdru8e8gah9mkv5fss5'));
$this->assertEquals($session->get('ohhai'), 1);
$this->assertEquals($session->get('userId'), 14);
$rawSession = $handler->getRaw(session_id());
$this->assertEquals($rawSession->getUserId(), 14);
}
示例13: testGateKeeperCheckBasic
public function testGateKeeperCheckBasic()
{
/* Set our stored DB session MANUALLY for testing */
session_id('k4o6898jdru8e8gah9mkv5fss5');
$handler = $this->di->get('session')->getHandler();
session_decode($handler->read('k4o6898jdru8e8gah9mkv5fss5'));
$gateway = new \Reservat\Auth\GateKeeper($this->di, $this->manager, 'Basic');
$result = $gateway->check();
if ($result['Basic']) {
$user = $result['Basic']->getUser();
$this->assertEquals($user->getUsername(), 'abc');
}
}
示例14: load
public final function load($session_id)
{
$string = $this->_load($session_id);
if (!is_string($string) && $string !== false) {
Mage::throwException('_load should return a string or false');
}
if (!$this->_decodeData) {
return;
}
if ($string) {
session_decode($string);
} else {
$_SESSION = array();
}
}
示例15: hookExpiredSession
public static function hookExpiredSession($sessionContents)
{
if (session_decode($sessionContents)) {
if (Zend_Auth::getInstance()->hasIdentity()) {
$identity = Zend_Auth::getInstance()->getIdentity();
$audit = new Audit();
$audit->objectClass = 'Logout';
$audit->userId = (int) $identity->personId;
$audit->message = __('user') . ': ' . $identity->username . ' ' . __('was logged out due to session expiration');
$audit->dateTime = date('Y-m-d H:i:s');
$audit->_ormPersist = true;
$audit->persist();
}
}
}