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

PHP獨立Session數(shù)據(jù)庫存儲操作類分享

直接上代碼:
復制代碼 代碼如下:
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

主站蜘蛛池模板: 中文字幕色站 | 999www成人 | 国产精品视频人人做人人爱 | www.欧美视频.com | 日本亚洲精品色婷婷在线影院 | 精品国产一区二区三区免费 | 国产欧美亚洲精品 | 亚洲国产一区视频 | 国内精品视频一区二区三区 | 成人国产欧美精品一区二区 | 六月婷婷啪啪 | 伊人激情 | 97碰公开在线观看免费视频 | 四虎在线最新永久免费 | 国产在线精品一区二区 | 国产91中文| 色婷婷久久免费网站 | 精品国产自在2o18 | 日日噜噜噜夜夜爽爽狠狠视频 | 久久亚洲精品视频 | 久久九九亚洲精品 | 国产亚洲综合视频 | 国产精品久久久久影视不卡 | 国产精品91在线播放 | 美女胸又大又黄又www的网站 | 日本在线视频www色 日本在线视频免费观看 | 东京道一本加勒无 | 国产成人综合日韩精品婷婷九月 | 浮力影院第一页小视频国产在线观看免费 | 欧美三级视频在线观看 | 搞黄网站在线观看 | 国产精品久久久久免费视频 | 国产精品1区2区 | 依人九九 | 欧美另类xxx精品人妖 | 在线亚洲欧美性天天影院 | 国产成人午夜视频 | a级精品九九九大片免费看 a加勒比一本东京 | 亚洲一区二区三区亚瑟 | 2021国内精品久久久久影院 | 美女把屁股扒开让男人桶视频 |