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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:48:17+00:00 2026-06-09T16:48:17+00:00

Basically I have a login system with basic session functionality, and it times out

  • 0

Basically I have a login system with basic session functionality, and it times out on browser close. I’ve been getting complaints on that so I want to be able to have some click the remember tick and have their session last for say, 30 days.

  • 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-09T16:48:19+00:00Added an answer on June 9, 2026 at 4:48 pm

    Set a cookie at the same time you’re setting the $_SESSION['user_id'] for instance. Like this :

    $token = hash('md5',$_SESSION['user_id'] . time() . 'salt');
    setcookie('token', $token, time() + (3600 * 24 * 30));
    setcookie('user_id', $_SESSION['user_id'], time() + (3600 * 24 * 30)); // Cookie expires in 30 days
    

    Save $token in DB in user_id row.

    Then you set the $_SESSION['user_id'] for users with cookies saved so they don’t have to sign in the normal way:

    if (!isset($_SESSION['user_id']) {
    
        if (isset($_COOKIE['user_id']) && isset($_COOKIE['token']) {
    
           $saved_token = SELECT token FROM users table WHERE userID = $_COOKIE['user_id'];
             if ($_COOKIE['token'] == $saved_token) { 
             $_SESSION['user_id'] = $_COOKIE['user_id'];
           } else log out
           }
    }  else log out
    }
    }
    

    Maybe that works better security wise?

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

Sidebar

Related Questions

Basically, I have a login.jsp page and a filter that checks if a session
Basically, I currently have login/ in urls.py redirect to the django.contrib.auth.views.login and that seems
I have this horribly stripped delphi code that basically login to server, save cookie
I'm using PHP5 here. I have made a login system that check's the username
I have a web application with login in system, and basically keeps you logged
Basically I have a simple login form. In the database I have a 'last_logged'
I basically have a program that filters records from one excel file to another
I basically have 7 select statements that I need to have the results output
How do I change the startup list? Basically I have a program that is
I am trying to manually implement a login system in ASP.NET 3.5. Basically, on

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.