Zen Cart Logo
Forums / General Questions / How to detect when the session has expired so i can run a clean up script

How to detect when the session has expired so i can run a clean up script

Views: 1,024

Results 1 to 4 of 4
24 Sep 2013, 12:09 PM
#1
strelitzia avatar

strelitzia

Totally Zenned

Join Date:
Nov 2005
Location:
France
Posts:
588
Plugin Contributions:
1

How to detect when the session has expired so i can run a clean up script

Hi,

Is there a built in function that i can use to trigger a php script to run when a session id has expired?

I'm temporarily writing information to a database and using $_SESSION['securityToken']; to ensure this data is only viewed by that session user. However, over time, this table will get bloated. I want to run a script to delete all data for the given session id once the time has expired.

Thanks

25 Sep 2013, 10:04 AM
#2
strelitzia avatar

strelitzia

Totally Zenned

Join Date:
Nov 2005
Location:
France
Posts:
588
Plugin Contributions:
1

Re: How to detect when the session has expired so i can run a clean up script

Nobody got any ideas on this? Any info from the dev team?

25 Sep 2013, 9:08 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How to detect when the session has expired so i can run a clean up script

Simple: add another field to your database table, such as 'expires_time' and store in it a timestamp that's for 30-90 minutes from whenever you insert it, and write code to clean up any entries that are older than that time.

25 Sep 2013, 9:11 PM
#4
strelitzia avatar

strelitzia

Totally Zenned

Join Date:
Nov 2005
Location:
France
Posts:
588
Plugin Contributions:
1

Re: How to detect when the session has expired so i can run a clean up script

That's what i'd thought of doing as my 'work around'.

I thought maybe there was a specific function within zc core to know when a session had expired.

Thanks Dr Byte. Always useful answers to obscure questions :)