Updating sessions
Posted: Sun Nov 15, 2009 5:09 am
I have a db table to store sessions for the sole purpose of admins being able to see active visitors on the site. One of the cells is a timestamp field.
Question #1
If the page is refreshed too fast (so that both page calls have the same timestamp) the 2nd page errors for trying to INSERT a duplicate. Is there anyway to avoid this other than putting a try/catch around the INSERT statement?
Question #2
Are there any real benefits to change MySQL's type to MEMORY for the sessions table?
Code: Select all
IF ( UPDATE_SESSIONS ) {
Remove sessions older than ten minutes
} ELSE {
There is no current session - INSERT one
}If the page is refreshed too fast (so that both page calls have the same timestamp) the 2nd page errors for trying to INSERT a duplicate. Is there anyway to avoid this other than putting a try/catch around the INSERT statement?
Question #2
Are there any real benefits to change MySQL's type to MEMORY for the sessions table?