I have typical problem with session variable
I have developed an application of placing order in rainola.com
Functionally it words fine but if a person surf other web sites and come back to the rainola.com he can still view the order details
| SitePoint Sponsor |
I have typical problem with session variable
I have developed an application of placing order in rainola.com
Functionally it words fine but if a person surf other web sites and come back to the rainola.com he can still view the order details


What's the expiration time on the session?
Alternatively, you might be able to use the referrer variable to destroy existing session if it's not from your site.


I think the solution here is to keep record of the last time the user was seen and if it's been too long then delete all session info (limiting the session lifespan like Arlen said is a way to achieve this).
Be wary that it could happen that the user left the window open the session would be destroyed even if the user didn't abandon the site.
There's no way to detect if the user went to other website.
Another option is using javascript onUnload event but, again, it is not infallible: javascript could be disabled and onUnload is fired when the users closes the window and when navigates to other site.

onunload (which is all lowercase as JavaScript) also fires when the page is reloaded and so would almost certainly not do what is required.
Sessions remain until one of three things happen.
1. Your visitor performs an action that you have set up to close the session (such as a logoff link where the session is being used when someone logs in)
2. They close their browser
3. The time period set on your server for session life span expires.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
Bookmarks