一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

PHP獨立Session數據庫存儲操作類分享

直接上代碼:
復制代碼 代碼如下:
class DbSession
{

    const TYPE_INT = 1;
    const TYPE_STR = 2;

    /**
     * Database configration
     *
     * @var array
     */
    private $_config = array(
            ‘host' => '127.0.0.1′,
            ‘port' => 3306,
            ‘username' => ‘root',
            ‘password' => ‘root',
            ‘dbname' => ‘db_mylab',
        ‘tablename' => ‘t_sessions',
        ‘cookie_prefix' => ‘mylab_',
        ‘cookiepath' => ‘/',
        ‘cookiedomain' => ”,
        ‘cookie_timeout' => 900
    );

    /**
     * Table fields type array
     *
     * @var array
     */
    private  $_db_fields = array(
        ‘crc32sid'      => self::TYPE_INT,
                ‘sessionhash'   => self::TYPE_STR,
                ‘idhash'        => self::TYPE_STR,
                ‘userid'        => self::TYPE_INT,
                ‘ipaddress'     => self::TYPE_STR,
                ‘lastactivity'  => self::TYPE_STR,
                ‘location'      => self::TYPE_STR,
        ‘loggedin'      => self::TYPE_INT,
        ‘heartbeat'     => self::TYPE_STR
        );

        /**
         * db obj
         *
         * @var mysqli object
         */
    private $_mysqli = null;

    /**
     * Weather the session was created or existed previously
     *
     * @var bool
     */
    private $_created = false;

    /**
     * Array of changes.
     *
     * @var array
     */
    private $_changes = array();

    /**
     * @var bool
     */

    private $_db_inited = false;

    /**
     * session host
     *
     * @var string
     */
    private $_session_host = ”;

    /**
     * session idhash
     *
     * @var string
     */
    private $_session_idhash = ”;

    private $_dbsessionhash = ”;

    private $_vars = array();

        public function __construct()
        {
                $this->_dbsessionhash = addslashes($this->get_cookie(‘sessionhash'));

            $this->_session_host = substr($_SERVER[‘REMOTE_ADDR'], 0, 15);

            #This should *never* change during a session
            $this->_session_idhash = md5($_SERVER[‘HTTP_USER_AGENT'] . self::fetch_substr_ip(self::fetch_alt_ip()) );

            $this->_init_config();
            $this->init_db();

            $gotsession = false;

            if ($this->_dbsessionhash)
            {
                $sql = ‘
                        SELECT *
                        FROM ‘ . $this->_config[‘tablename'] . ‘
                        WHERE   crc32sid = ‘ . sprintf(‘%u', crc32($this->_dbsessionhash)) . ‘
                            AND sessionhash = '‘ . $this->_dbsessionhash . ‘'
                                AND idhash = '‘ . $this->_session_idhash . ‘'
                        AND heartbeat > '‘ . date(‘Y-m-d H:i:s' ,TIMENOW

主站蜘蛛池模板: 亚洲一级特黄 | 亚洲精品国产国语 | 久久99精品一级毛片 | 日本韩国欧美在线 | 国产小视频在线观看www | 精彩国产熟睡乱子伦午夜片 | 国产拳头交一区二区 | 精品日韩欧美国产一区二区 | 欧美人善zozσ性伦交 | 黄色在线网站 | 国产美女在线精品免费观看 | 国产91对白在线播放 | 亚洲国产成人在人网站天堂 | 日本在线加勒比 | 99在线精品日韩一区免费国产 | 国产精品自在自线 | 欧洲大胆a级人体 | 亚洲天堂国产精品 | 久久亚洲综合网 | 伊人激情综合网 | 玖玖精品视频 | 91视频一区 | 青青草伊人久久 | 一级做α爱过程免费视频 | 亚洲天堂网站 | 欧美a级黄色片 | 久久亚洲精品国产精品婷婷 | 激情亚洲综合网 | 日本加勒比在线观看 | 亚洲一区小说区中文字幕 | 亚洲一道本 | 久久国产乱子免费精品 | 最近中文字幕完先锋资源 | julia一区二区三区中文字幕 | 真实国产乱弄免费视频 | 免费激情网 | 精品中文字幕在线观看 | 国产成品精品午夜视频 | 中文字字幕码一二区 | 六月婷婷网视频在线观看 | 国产在视频线精品视频www666 |