I have a Classic ASP site, that requires some database tables to be emptied out of session data on a schedule. This system doesn’t have access to scheduled tasks (it’s on a shared web host, and using MySQL server)
I was considering using global.asa, to fire off events as such:
Application_OnStart– delete all session data from databaseApplication_OnEnd– delete all session dataSession_OnStart– create a user’ sessionSession_OnEnd– delete all session data that relates to this session.
Is there any reason why I shouldn’t create database connections in global.asa? These will be created and destroyed here, no shared on session or application scope. I see it as a way of running these admin tasks twice per user (on session start and end) and not being fired again for them equating to very little database traffic.
Anyone have any ideas as to why this may be bad? Any reasons to not connect to a database in global.asa?
If anyone thinks the above idea is a bad one – do you have any other thoughts as to how I can regularly empty these tables without one or more of:
- Scheduled task
- Database scheduled task
- Running the code on page load for every page (hence the
Session_OnStarthooks)
Ta’
Senior Coconut
I’d do cleanup for single session in
Session_OnEndand for ALL sessions inApplication_OnStart. If your all-sessions-cleanup is slow, you can do a ugly thing and put that cleanup in a separate asp-file that you make a http-request to using the XMLHTTP class, remember to not wait for the request to complete as it won’t begin being served before all code inApplication_OnStartis run.