开发者

How to store sessions with PHP

开发者 https://www.devze.com 2023-04-11 03:39 出处:网络
I am trying to create a PHP session class to store sessions.What is the best way to deal with sessions?

I am trying to create a PHP session class to store sessions. What is the best way to deal with sessions?

This is what I have so far:

class Sessions {

    function start() {
        session_start();
        $_SESSION['sid'] = randomstring();
        // insert session id into db
        // initialize user data
    }

    function destroy() {
        session_destroy();
        // delete开发者_开发百科 sid from db too
    }

    function update() {
        session_regenerate_id();
        // update lastaccess time in db
    }
}

What is the best way to store sessions in PHP?


This will answer your question of Session Handling? http://www.devshed.com/c/a/PHP/Storing-PHP-Sessions-in-a-Database/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号