Session in PHP using class

1

Hello, I'm new to PHP and would like to know how to create a class to manage the user session.

It would be a function to start the session and another to destroy the session.

If you have how to create, how could I be doing this?

    
asked by anonymous 19.12.2015 / 20:24

1 answer

3

If I understand correctly, you want a class that has the function of starting and destroying a session, so here's a brief example

class Session {
    public static function init() {
        if(session_id() == '') {
            session_start();
        }
    }

    public static function destroy() {
        session_destroy();
    }
}
    
19.12.2015 / 21:05