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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:56:41+00:00 2026-05-27T18:56:41+00:00

I am building a online ticket booking site . In this I am doing

  • 0

I am building a online ticket booking site . In this I am doing the following things : The user searches the bus with their seat numbers . The database is updated with the seat numbers with temp_seat_book = 'Y' . If he books the ticket paying money his status will be updated to final_ticket_book = 'Y' . Now I want to delete the field whose temp_seat_book = 'Y' but
final_ticket_book = 'N' . For this I need to delete the session_ids which is more than 10minutes old and final_ticket_book = 'N'. So how I can implement the background job?

  • 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-27T18:56:42+00:00Added an answer on May 27, 2026 at 6:56 pm

    Instead of doing a search for files (which involves more i/o ) etc,
    What is a session cookie: Session Cookie
    A better way is to store a time stamp of the ‘most recent activity’ in the $_SESSION variable.
    And updating the session data on every request (including the automated periodic ajax calls if any).

    Lets say you want to unset the session after 10 minutes,

    if (isset($_SESSION['most_recent_activity']) && 
        (time() -   $_SESSION['most_recent_activity'] > 600)) {
    
     //600 seconds = 10 minutes
     session_destroy();   
     session_unset();  
    
     }
     $_SESSION['most_recent_activity'] = time(); // the start of the session.
    

    To avoid attacks like Session fixation: (Session Fixation is an attack that permits an attacker to hijack a valid user session) keep regenerating the session id periodically say for 5 mins (I would suggest to keep the regeneration time as well as session expire time a bit more). A more elaborate list of attacks: attack list.

    if (!isset($_SESSION['CREATED'])) {
        $_SESSION['CREATED'] = time();
        } 
    else if (time() - $_SESSION['CREATED'] > 600) {
        session_regenerate_id(true);    
        $_SESSION['CREATED'] = time();  
        }
    

    Also, make sure session.gc-maxlifetime is set to the maximum expire time you want to use.
    You can do this

    ini_set('session.gc-maxlifetime', 600)
    

    Or
    Set it directly in your php.ini.

    and also

    session.cookie_lifetime :

    session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser.

    But, destroying the session must be taken care at the server-side and not the client-side.
    Setting the session.cookie_lifetime set to 0 would make the session’s cookie behave the way a session cookie should i.e. that a session cookie is only valid until the browser is closed.

    Although this method is a tad tedious, Its more elegant.

    Ah, found the link which I had read a long time ago! : How do I expire a PHP session after 30 minutes?

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

Sidebar

Related Questions

I am planning to make an online bus ticket reservation systems . In this,
noob question: I'm building a checkout system for an online commerce site. I'm getting
I'm building a simple application. It's a user interface to an online order system.
What are some recommended WordPress plugins that make building an online user manual more
I am building an online hotel booking system.... Using php and mysql.... Users can
I'm building a online font previewer, with following architecture. I wrapped preview creation function
Background to question: We are building an online web application that requires the user
I am building an online shop website that lets a user buy items online.
I'm building an online editor where the language is set by the user settings
We're building a online-store/site for a winery, and they have a matrix/table of shipping

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.