Jump to content

session start and session end events


alluoshi

Recommended Posts

Hello, I am working on a session-based multi-user web application (through Apache, php and mysql). When a user logs in, a new session starts. I would like to write a program to save this information:

1- the username who joined (originally created in mysql)

2- session id

3- session start date

4- session end date (when the user logs out, or when the browser is closed)

so when the session ends, I want this information to be saved in mysql database (the username will be saved in Table "users" and the session_id, session_start_time and session_end_time will be saved in Table "Sessions"

Any idea about how to solve this problem?

Link to comment
Share on other sites

#1-#3 are easy to do, but #4 isn't possible as you describe. you can track when the user clicks Log Out, and record that. but as far as when the browser is closed, you will never be notified about that. you can though, track the last time the user did anything, then either use that or have a cronjob that goes through and records a 'session end date' for anything that has been stale for say...20 minutes

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.