bmacnaughton Posted May 13, 2016 Posted May 13, 2016 I need to write a lazy cron job that goes through a list of files and deletes those that are associated with expired sessions. Our session information is stored in the DB table sessions. Is there a Wire API call that allows me to do one of: 1) fetch all expired sessions? 2) hook the session expiration event? 3) fetch all active sessions? 4) do direct DB access to lookup sessions? (least preferred as I have to directly tie to session implmentation). My logic can either flow: Find active sessions delete files NOT in active sessions Get files if session_id associated with file NOT in sessions (or has expired) delete file.
bmacnaughton Posted May 14, 2016 Author Posted May 14, 2016 OK, I found this https://processwire.com/talk/topic/17-functionsmethods-to-access-the-db/ and can figure it out from here.
DaveP Posted May 14, 2016 Posted May 14, 2016 Just to note that the thread linked above is from quite some time ago and talks only about the $db (mysqli) object. Since PW 2.4 the $database (pdo) object has also been available. See https://processwire.com/talk/topic/3515-processwire-24-compatibility-for-modules/#entry34647 3
adrian Posted May 14, 2016 Posted May 14, 2016 OK, I found this https://processwire.com/talk/topic/17-functionsmethods-to-access-the-db/ and can figure it out from here. Keep in mind that post is very old. We now use $database: https://processwire.com/api/ref/database/ Beaten by @DaveP 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now