Jump to content

Session question


Don E

Recommended Posts

Hello everyone,

 

I've done some search into the following but not sure what is the best route to take regarding sessions.

 

If I have a cron job to do something at a certain time of the day, like delete files to free up space etc, what would be recommended to not have the cronjob delete the files where the file names of those files are stored in session for that user whose session is currently active?

 

There is a session_status function which checks if any sessions are active but that is only for PHP 5.4 and up.

 

Thanks.

Link to comment
Share on other sites

It's probably better to store those filenames somewhere less volatile and more accessible, like in a database or a file.

 

You would need to keep track of sessions using a cron job then, though.

Link to comment
Share on other sites

There is a session_status function which checks if any sessions are active but that is only for PHP 5.4 and up.

That still only describes the status of a single user's session, not any session on the server. But, is the version a problem for you? You're not still using a 6 year old version of PHP, are you?One option is to use a custom session handler to store your sessions in a database. Another option using the default session handler is to read every session file and parse it to check for filenames.
Link to comment
Share on other sites

Yes, you use this function:http://php.net/manual/en/function.session-set-save-handler.phpIt's not a good idea to use the mysql extension at this point though, you're better off using PDO.

 

Is mysqli okay? I'm sure it is but I assume you mentioned that because the article is written using the mysql extension and it's no longer recommended to use the mysql extension but just to ask, is mysqli still okay even though its not as portable as PDO?

 

Thanks.

Edited by Don E
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...