in reply to Re^2: End of a user's session
in thread End of a user's session

How can I delete a temporary file associated with a user's session ID when he/she closes his/her browser?

It is very difficult (impossible?) to do that in a reliable way. If the temporary files (or database entries, or whatever you use for session tracking) start to bother you, you should set a session timeout. If you do not hear from the user for, say, two hours, delete the file. Can be done with a cron job.

Replies are listed 'Best First'.
Re^4: End of a user's session
by Joost (Canon) on Dec 20, 2004 at 20:34 UTC
    How can I delete a temporary file associated with a user's session ID when he/she closes his/her browser?
    It is very difficult (impossible?) to do that in a reliable way.
    It's impossible. There is no real implementation of "the end of a session" - there is only a session ID that's passed on every request to the site (if at all). All you can do is run some code when the session times out, and you'll never know for sure wether a user has closed his browser, disabled cookies, moved to another site, or had his computer bust into flames.