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

  • Home
  • SEARCH
  • 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 8947545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:47:22+00:00 2026-06-15T12:47:22+00:00

I have a single form for login for both admin and general users. I

  • 0

I have a single form for login for both admin and general users. I would like to time the sessions out after 30 minutes how would I amend my current code to do that?

<?php
    session_start(); //Start the session
    define(ADMIN,$_SESSION['username']); //Get the user name from the previously registered super global variable

    if(!session_is_registered("admin")){ //If session not registered
        header("location:../index.php"); // Redirect to login.php page
    }
?>
  • 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-15T12:47:23+00:00Added an answer on June 15, 2026 at 12:47 pm

    Here is the code to clear the session for a specified time.

    To clear the inactive session, you have to renew the session timeout every page.
    Hope it helps.

    For reference, http://bytes.com/topic/php/insights/889606-setting-timeout-php-sessions

    session_start();
    $timeout = 60; // Number of seconds until it times out.
    
    // Check if the timeout field exists.
    if(isset($_SESSION['timeout'])) {
        // See if the number of seconds since the last
        // visit is larger than the timeout period.
        $duration = time() - (int)$_SESSION['timeout'];
        if($duration > $timeout) {
            // Destroy the session and restart it.
            session_destroy();
            session_start();
        }
    }
    
    // Update the timout field with the current time.
    $_SESSION['timeout'] = time();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a simple login form (or any form for that
I have Login form,forget password form and register form in a single page.. What
I have two types of roles [Admin, HelpDeskAdmin]. I have a single logon view(both
I want to use a single form to login normal users and admins, i
I'd like to have a single form that has 2 or more field-set_tags and
I have a single form that, depending on which radio button is clicked (Login
I have a simple login page and the URL structure is like www.mydomain.com/admin/auth I
Assume we have a single Windows form with a button called SimpleButton1. The following
I have A single page that has the following structure <form runat=server><placeholder></placeholder></form> I have
I have a simple form with a single button and a datatable with a

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.