Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 28th, 2010, 05:26 AM
Authorized User
 
Join Date: Mar 2009
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default what are the ways session can be expired in the browser

Dear all

Please tell me
what are the ways session can be expired in the browser

Thanks,
Thava
 
Old March 29th, 2010, 12:03 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

That has to do with how your application handles cookies. I don't know about forcing the master session to expire, I've had a lot of problems specifically expiring sessions in C#. Manipulating the master session has been highly unreliable, so here's how "I" do it.

When I create a session, I don't want to store any user information, the more user info you stick there, the more information is stuffed into the cookie decreasing application performance and storing valuable information (valuable enough that you wanted to have it in the session) in a terribly insecure location. Therefore, I store only custom id number (and a checksum) in the master session. This effectively creates my own custom session using the master session as machinery to make it work. Then I can work sessions, like this.

I. When someone logs in I store a new session id in my custom session and in the user record of the database. I also add my expiration time to the current timestamp and store the expiration time in the user record as well.

II. When someone arrives at a page, I check to see if they have my custom session id stored in the session. If they don't they're not logged in. if they do, I hit the database and find the user record for that session id; this lets me identify the user. I can simultaneously pull any user information I need to customize the page at the same time, the user data are the fields I request in the SELECT statement and the session id is the WHERE clause that specifies the record I want.

One of the items I always grab is the expiration timestamp. I compare that to the current time which allows me to manually expire the session and I also evaluate the checksum to determine if someone has manipulated the session data. If either is not kosher I execute an UPDATE that erases the session id and resets the timestamp to wipe out that invalid session. If everything is OK, then I have a valid user who is logged in and I execute the application logic to customize the page for them.

III. If someone logs out, I execute the same UPDATE statement to invalidate the session.
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.





Similar Threads
Thread Thread Starter Forum Replies Last Post
invalidate the session on closing of browser VinodTewthia Pro JSP 4 July 21st, 2007 12:12 AM
Session Expired Redirect acdsky Classic ASP Basics 7 August 28th, 2006 03:24 AM
error:(session expired) hara_sap Servlets 0 March 18th, 2005 05:54 AM
How to close a browser session ? elisabeth Pro JSP 2 April 11th, 2004 11:30 PM
Expired CR9 session kills IIS darkov Crystal Reports 0 March 15th, 2004 05:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.