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 7844085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:46:07+00:00 2026-06-02T16:46:07+00:00

I am new at PHP and even newer with PHP Sessions, but have been

  • 0

I am new at PHP and even newer with PHP Sessions, but have been reading a lot about it; however, I haven’t been able to find the answer to my problem. Here is a simplified version:
1 – user types in a name in a form on a page
2 – a php file gets the name, starts a session and creates a directory on the server for the user with some customized files that the user can view.

Here is the question:
Since this is not a true login mechanism there won’t be a logout or session timeout and I don’t want to impose a timeout. So as long as s/he has the browser page open the directory that was created for the user on the server should be still accessible. How do I know when the browser is closed and user is not using the session anymore so I can delete the custom directory on the server? Is there anything related to the session file that is on the server that can be used: for example, if the garbage collection cleans the session and it doesn’t exist anymore then I could run a script to detect that and delete the directory associated with the deleted session.

What is not clear to me is what happens to sessions on the server if session_destroy() is never called.

  • 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-06-02T16:46:08+00:00Added an answer on June 2, 2026 at 4:46 pm

    Since this is not a true login mechanism there won’t be a logout or session timeout and I don’t want to impose a timeout.

    Actually – it is a true login mechanism – you have a user perform a login by “entering name on form” – then they are logged in. It is just different to a username.

    You just dont have a “logout” mechanism.

    You can not rely on a browser to tell you when it is closed, leaving etc – it is unreliable and will not work. Therefore – your best (and only real) solution is to check server side for the state of the session. Just create a CRON job that runs a php file every 15mins or so. Each time the php file is run – it checks all sessions for their last activity time. If the last activity time is longer than the timeout limit, then run your cleanup.

    I know you said you dont want to “impose a timeout” – but you’ll going to have to draw a line in the sand somewhere, and say “hey, if my users are inactive for X mins (or even X hours) – then it is safe to assume they have left and are not coming back!”. Just set a really high threshold.

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

Sidebar

Related Questions

I'm quite new to php and have been reading Larry Ullman book to develop
Am new to php... I have been battling on my dynamic checkboxes in such
Please forgive the ignorance, but I'm very new to PHP and I couldn't find
I am new to php. I want to have a form such as this:
I am migrating my Facebook canvas application to using the new PHP SDK. However,
Im new to PHP Object Oriented Programming but I know to code in procedural
I have never upgraded my version of PHP but feel I need to to
all. I've been thinking about a design decision for a PHP form and I'd
I am relatively new to mod_rewrite, but have a site which I would like
I'm sure this question has been asked before, but I'm too frustrated to find

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.