Jump to content
xisto Community
Sign in to follow this  
vicky99

Session And Security

Recommended Posts

Hi everyone, I'd like to explain my idea for basic session handling to you guys. I've thought about it, and I can't see any problem with it, but I'd like other's opinions as well, please. Ok, here goes. So basically, there's two base cases that can happen. User visits any page, session class is initialized, etc. Case 1 - User not logged in; no cookie or session info in DB If the user is not logged in, has no cookie, and/or there is no session info in the DB for this user, any specified activities, protected like so: php: if ( $session->loggedOn() == FALSE ) { ... } the user cannot access them. If the user logs in, the session class will attempt to set a cookie containing a random session_id, which is stored in the database. If a cookie is unavailable, the session_id is still stored in the DB, and the SID is appended to the URL. $session->loggedOn() is set to true, and the user can access previously restricted areas. Case 2 - User is logged in If the user is logged in, the session class first looks for the cookie. If it's found, and the info (session_id, session_key) is valid, $session->loggedOn() remains at true, and the last_visited time in the DB is updated. In the constructor is a removeInactive(), which removes sessions that are inactive after a certain amount of time. There is also updateSession(), which does the checking for a session. On logout, all info is scrubbed, and removeInactive() is also called, closing the session.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.