Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7587569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:42:22+00:00 2026-05-30T19:42:22+00:00

I am looking at how I can run a script or function when a

  • 0

I am looking at how I can run a script or function when a user’s session ends so that I can delete temporary files which may be required.

I have searched around SO to find a solution to this problem and came across this but I find I am a little out of my depth and I find the PHP documentation regarding GC to be confusing (and from what I understand from the documentation – it is not really what I need).

I looked at the page on session_set_save_handler and came up with this:

session_set_save_handler( '', '', '', '', 'deleteDocs');
function deleteDocs()
{
    rmdir('user/' . rawurlencode($_SESSION['data']['user']['details']['email']) . '/temp');
}

However, this function does not run at all. Frankly, with this, I feel like I do not know what I am really doing.

I tried using GC and looked at session.gc_divisor and session.gc_probability but I cannot edit php.ini anyway.

Can this be achieved. Should I be using a cron job – if so, how can I check that sessions are finished?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:42:23+00:00Added an answer on May 30, 2026 at 7:42 pm

    Should I be using a cron job – if so, how can I check that sessions are finished?

    Yes. You do this based on the file last modification time (in your case the file is a directory). If it’s older than the maximum session age, delete the directory.

    You can use the findWikipedia command for that.

    You find an example script in your PHP folder, see as well Deleting old session files from custom set session folder? and cleanup php session files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a tool that I can run against my code base to
I am looking for a cross platform Library in C++ that can run a
I'm looking for a lightweight, easy to setup CI server that I can run
How can I run a CMD or .bat file in silent mode? I'm looking
Im looking for somthing that can belong to many many models and, hopfully, has
Looking around, I can't name a single web application (not web service) that uses
I have a script called notify_me.php which I run like so: script type=text/javascript> //Run
How can I disable the dangerous eval function? Can that be done using ini_set
I wrote a PHP script to delete files selected in a gridview. This is
Hey! i'm looking for some way that can help me in task like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.