954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Session end

Is there any way to ensure that a particular code is executed when a session ends e.g to remove temporary files og database entries ? similar to the Session_OnEnd in the global.asa file in an asp application ?

bratbo
Newbie Poster
3 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

That depends on what session method you are using. Are you using standard file based sessions or have you written a session handler that uses MySQL? :)

(assuming I have understood your question correctly).

Shorty
Newbie Poster
3 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

That depends on what session method you are using. Are you using standard file based sessions or have you written a session handler that uses MySQL? :)

(assuming I have understood your question correctly).

I am thinking i terms of standard php sessions (cookie og querystring based)
Regards
Martin Bratbo

bratbo
Newbie Poster
3 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

Did you ever get this figured out. I would also like to delete temp files that are associated with a specific session if that session has ended.

melban
Newbie Poster
2 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

If I'm not mistaken PHP automatically handles garbage collection and cleanup when a session ends. That is provided you haven't declared any custom session handlers using session_set_save_handler().

DanceInstructor
Posting Whiz
368 posts since Feb 2005
Reputation Points: 17
Solved Threads: 14
 

PHP does handle it's own garbage colleciton. What I was getting at was the ability to save uploaded files to a custom temp directory (not php tmp) but delete those files when the session was destroyed.

I'm getting around this buy actually loading the file contents into the session. makes for a large session file but that is the only problem i've had so far.

If I'm not mistaken PHP automatically handles garbage collection and cleanup when a session ends. That is provided you haven't declared any custom session handlers using session_set_save_handler().
melban
Newbie Poster
2 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

That's interesting :)

DanceInstructor
Posting Whiz
368 posts since Feb 2005
Reputation Points: 17
Solved Threads: 14
 

I think there is no direct way in PHP. This can be done using Global.aspx file in asp.net.

For PHP work around, we can keep the list of created sessiond and then checking for the each sessions if they are available. If any session is found destroyed, we can delete the uploaded files by that session. However, this adds additional efforts managing the session tables along with the list of uploaded files per session.

thewebhostingdi
Junior Poster
168 posts since Jun 2009
Reputation Points: 3
Solved Threads: 14
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You