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


PHP session_encode函数代码示例

本文整理汇总了PHP中session_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP session_encode函数的具体用法?PHP session_encode怎么用?PHP session_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: CloseSessionIfEmpty

function CloseSessionIfEmpty()
{
    $encoded = @session_encode();
    if (false !== $encoded && 0 == strlen($encoded)) {
        session_destroy();
    }
}
开发者ID:TheYorkerArchive,项目名称:codebase-2006-2012,代码行数:7,代码来源:init_helper.php

示例2: 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();
 }
开发者ID:nextbook438,项目名称:osezno-php-framework,代码行数:35,代码来源:dataModel.php

示例3: mysql_session_read

function mysql_session_read($SID)
{
    $ip = $_SERVER['REMOTE_ADDR'];
    $sql = "\n    SELECT data,refresh,playerid \n    FROM l_session \n    WHERE id = '{$SID}' \n    and expire > now() \n  ";
    $res = mysql_query($sql);
    if ($res) {
        $row = mysql_fetch_assoc($res);
        if ($row) {
            $session = stripslashes($row['data']);
            if ($row['refresh'] == 'Y' and !empty($row['playerid'])) {
                $_SESSION = unserialize_session_data($session);
                session_data_reload($row['playerid']);
                $session = session_encode();
                unset($_SESSION);
                $sql = "UPDATE l_session SET refresh='N' WHERE id='{$SID}'";
                mysql_query($sql);
            }
            return $session;
        } else {
            mysql_session_destroy($SID);
        }
    }
    sessionStaticInfo();
    return "";
}
开发者ID:szakats,项目名称:bzflag_mirror,代码行数:25,代码来源:session.php

示例4: PrintPageHeader

function PrintPageHeader()
{
    global $DBtype, $ADODB_vers;
    $tmp = session_encode();
    $php_version = phpversion();
    $ver = $php_version[0];
    $request_uri = XSSPrintSafe($_SERVER['REQUEST_URI']);
    if ($ver >= 5 || $ver == 4 && $php_version[1] >= 1) {
        if (array_key_exists("HTTP_REFERER", $_SERVER)) {
            $http_referer = XSSPrintSafe($_SERVER['HTTP_REFERER']);
        } else {
            $http_referer = "";
        }
    } else {
        if (key_exists("HTTP_REFERER", $_SERVER)) {
            $http_referer = XSSPrintSafe($_SERVER['HTTP_REFERER']);
        } else {
            $http_referer = "";
        }
    }
    $http_user_agent = XSSPrintSafe($_SERVER['HTTP_USER_AGENT']);
    $server_software = XSSPrintSafe($_SERVER['SERVER_SOFTWARE']);
    $query_string = XSSPrintSafe($_SERVER['QUERY_STRING']);
    echo "<PRE>\n         <B>URL:</B> '" . $request_uri . "'\n         (<B>referred by:</B> '" . $http_referer . "')\n         <B>PARAMETERS:</B> '" . $query_string . "'\n         <B>CLIENT:</B> " . $http_user_agent . "\n         <B>SERVER:</B> " . $server_software . "\n         <B>SERVER HW:</B> " . php_uname() . "\n         <B>DATABASE TYPE:</B> {$DBtype}  <B>DB ABSTRACTION VERSION:</B> {$ADODB_vers}\n         <B>PHP VERSION:</B> " . phpversion() . "  <B>PHP API:</B> " . php_sapi_name() . "\n         <B>BASE VERSION:</B> " . $GLOBALS['BASE_VERSION'] . "\n         <B>SESSION ID:</B> " . session_id() . "( " . strlen($tmp) . " bytes )\n         </PRE>";
}
开发者ID:jhbsz,项目名称:ossimTest,代码行数:25,代码来源:base_log_error.inc.php

示例5: read

 /**
  * Read session data
  *
  * @param string $id
  * @return string
  */
 public function read($id)
 {
     $_SESSION = json_decode($this->memcached->get("sessions/{$id}"), true);
     if (isset($_SESSION) && !empty($_SESSION) && $_SESSION != null) {
         return session_encode();
     }
     return '';
 }
开发者ID:lboynton,项目名称:memcached-json-session-save-handler,代码行数:14,代码来源:Memcached.php

示例6: cloneSessionId

 /**
  * Returns a cloned session id
  *
  * This feature enables session data cloning, and is useful when you want to call scripts using
  * localhost keeping your actual session opened.
  *
  * What is done by cloneSid :
  * - a new session id is registered
  * - the new session file is immediately created with the data of the current session
  *
  * @return string the cloned session id
  */
 public static function cloneSessionId()
 {
     $old_id = session_id();
     session_regenerate_id();
     $new_id = session_id();
     file_put_contents(session_save_path() . SL . 'sess_' . $new_id, session_encode());
     session_id($old_id);
     return $new_id;
 }
开发者ID:TuxBoy,项目名称:Demo-saf,代码行数:21,代码来源:Session.php

示例7: testSessionWrite

 public function testSessionWrite()
 {
     $_SESSION['test'] = "some string";
     $_SESSION['mongo'] = "Cool DB!";
     $expected = session_encode();
     session_write_close();
     $database = $this->mongo->selectDB("session");
     $sessions = $database->selectCollection("session");
     // Only select the session data with id = session_id()
     $data = $sessions->findOne(array('session_id' => session_id()), array('data'));
     $this->assertEquals($expected, $data['data']);
 }
开发者ID:halfdan,项目名称:MongoSession,代码行数:12,代码来源:MongoSession.test.php

示例8: read

 /**
  * Read the id
  * @param string $id The SESSID to search for
  * @return string The session saved previously
  */
 public function read($id)
 {
     $tmp = $_SESSION;
     $_SESSION = json_decode($this->memcache->get("sessions/{$id}"), true);
     if (isset($_SESSION) && !empty($_SESSION) && $_SESSION != null) {
         $new_data = session_encode();
         $_SESSION = $tmp;
         return $new_data;
     } else {
         return "";
     }
 }
开发者ID:kerrer,项目名称:vagrant,代码行数:17,代码来源:memcacheSessionHandler.php

示例9: close

  public function close() {
   $rid = rand();
//   addtologEx ('session', $rid.' saving session file '.$this->savePath."/sess_".$this->id);
   
   $data = session_encode();
   if ($data) {
    file_put_contents($this->savePath.'/sess_'.$this->id, $data);
   }
   
//   addtologEx ('session', $rid.' data: '.print_r($data,true));
   
//   echo "close";
   return true;
  }
开发者ID:AragCF,项目名称:extmail2,代码行数:14,代码来源:Session.1.2.php

示例10: read

 /**
  * Gets json_encoded Session data from Redis
  * and encode it back to php's session encoding
  */
 public function read($id)
 {
     $tmp = $_SESSION;
     $id = $this->redisKeyPath() . $id;
     $_SESSION = json_decode($this->client->get($id), true);
     $this->client->expire($id, $this->ttl);
     if (isset($_SESSION) && !empty($_SESSION) && $_SESSION != null) {
         $new_data = session_encode();
         $_SESSION = $tmp;
         return $new_data;
     } else {
         return "";
     }
 }
开发者ID:swilsonalfa,项目名称:TrafficAdvisor,代码行数:18,代码来源:RedisSessionHandler.php

示例11: session_clear

function session_clear()
{
    // if session exists, unregister all variables that exist and destroy session
    $exists = "no";
    $session_array = explode(";", session_encode());
    for ($x = 0; $x < count($session_array); $x++) {
        $name = substr($session_array[$x], 0, strpos($session_array[$x], "|"));
        if (session_is_registered($name)) {
            session_unregister('$name');
            $exists = "yes";
        }
    }
    if ($exists != "no") {
        session_destroy();
    }
}
开发者ID:rzs840707,项目名称:webapps_repository,代码行数:16,代码来源:clear.php

示例12: testReadWrite

 /**
  * @runInSeparateProcess
  */
 public function testReadWrite()
 {
     session_start();
     $saveHandler = new Memcached($this->memcached);
     $this->assertTrue($saveHandler->open('savepath', 'sessionname'));
     $id = session_id();
     $_SESSION = array('foo' => 'bar', 'bar' => array('foo' => 'bar'));
     $this->assertTrue($saveHandler->write($id, session_encode()));
     $this->assertEquals($_SESSION, json_decode($this->memcached->get("sessions/{$id}"), true));
     $serializedSession = $saveHandler->read($id);
     $this->assertTrue(!empty($serializedSession));
     $_SESSION = array('foo' => array(1, 2, 3));
     $this->assertTrue($saveHandler->write($id, serialize($_SESSION)));
     $this->assertEquals($_SESSION, json_decode($this->memcached->get("sessions/{$id}"), true));
     $serializedSession2 = $saveHandler->read($id);
     $this->assertTrue(!empty($serializedSession2));
 }
开发者ID:lboynton,项目名称:memcached-json-session-save-handler,代码行数:20,代码来源:MemcachedTest.php

示例13: processLogout

function processLogout()
{
    if (!checkSession()) {
        return;
    }
    // Reset Session Values
    $_SESSION['adminAuth'] = '';
    $_SESSION['adminTime'] = '';
    // If session exists, unregister all variables that exist and destroy session
    $exists = false;
    $session_array = explode(";", session_encode());
    for ($x = 0; $x < count($session_array); $x++) {
        $name = substr($session_array[$x], 0, strpos($session_array[$x], "|"));
        if (session_is_registered($name)) {
            session_unregister('$name');
            $exists = true;
        }
    }
    if ($exists) {
        session_destroy();
    }
}
开发者ID:engineerisaac,项目名称:bf2142stats_emu,代码行数:22,代码来源:admin.security.php

示例14: Start

 public function Start()
 {
     if ($this->getIsSessionStarted(true)) {
         return;
     }
     $request_type = getenv('HTTPS') == 'on' ? 'SSL' : 'NONSSL';
     // set the cookie domain
     $cookie_domain = $request_type == 'NONSSL' ? \src\classes\Environment::HTTP_COOKIE_DOMAIN : \src\classes\Environment::HTTPS_COOKIE_DOMAIN;
     $cookie_path = $request_type == 'NONSSL' ? \src\classes\Environment::HTTP_COOKIE_PATH : \src\classes\Environment::HTTPS_COOKIE_PATH;
     $currentSession = null;
     // set the session cookie parameters
     if (function_exists('session_set_cookie_params')) {
         session_set_cookie_params(0, $cookie_path, $cookie_domain);
     } elseif (function_exists('ini_set')) {
         ini_set('session.cookie_lifetime', '0');
         ini_set('session.cookie_path', $cookie_path);
         ini_set('session.cookie_domain', $cookie_domain);
     }
     $sessionId = isset($_COOKIE['sessionId']) ? $_COOKIE['sessionId'] : md5(uniqid(rand(), true));
     if (!isset($_COOKIE['sessionId'])) {
         setcookie('sessionId', $sessionId, time() + 60 * 60 * 24);
     } else {
         session_id($sessionId);
         session_start();
         $currentSession = session_encode();
         session_destroy();
         $sessionId = md5(uniqid(rand(), true));
         setcookie('sessionId', $sessionId, time() + 60 * 60 * 24);
     }
     session_id($sessionId);
     session_start();
     if ($currentSession !== null) {
         session_decode($currentSession);
     }
     $hasCookies = false;
     $this->setIsSessionStarted(true);
     $this->RegisterVariable('sessionId', $sessionId);
 }
开发者ID:Waryway,项目名称:Website,代码行数:38,代码来源:Session.php

示例15: session_close

function session_close()
{
    global $session, $SID;
    if ($session->nr_open_sessions == 0) {
        return false;
    }
    // Encode session
    $val = session_encode();
    $len = strlen($val);
    // Save session
    $mod = $GLOBALS[$session->mod_name];
    if (!$mod->write($session->id, $val)) {
        die('Session could not be saved.');
    }
    // Close session
    if (function_exists($session->mod_name . '->close') && !$mod->close()) {
        die('Session could not be closed.');
    }
    $SID = '';
    $session->nr_open_sessions--;
    return true;
}
开发者ID:jobw0110,项目名称:lascolinasobgyn,代码行数:22,代码来源:sessions.php


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