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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:42:51+00:00 2026-05-13T08:42:51+00:00

I use a simple login system based on SESSION vars. Once the user logs

  • 0

I use a simple login system based on SESSION vars. Once the user logs in, a session var is set that tells my script the user is to be accepted in. I don’t use any custom clientside cookie var.

I would like to offer the option on the login screen that says “keep me loggued in the whole day”. How does one do that in a secure way?

  • 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-13T08:42:51+00:00Added an answer on May 13, 2026 at 8:42 am

    First: Configure the session.cookie_lifetime directive, either in php.ini, configuration files, or via session_set_cookie_params().

    Next, store the username and the hash value of the password in the session, and validate that login on every page. As long as it’s still valid, they get to stay logged in.

    The session cookie’s natural expiration should generally keep things tidy, as you won’t have anyone getting logged out in the middle of their session (if the stars aligned for it, of course) if they keep it active. Failing that, though, I’d consider eCartoth’s solution a close second, as you could just add a second line to the if statement:

    if (my_validate_user_function($_SESSION['username'],$_SESSION['passhash']) 
        && $_SESSION['deathstamp'] > time()
    ) {
        // user is logged in again, oh boy!
    }
    else {
        // send in the death robots
        header('Location: /login.php',true,302);
    }
    

    EDIT: One thing you might want to consider is session fixation and/or session hijacking. In order to prevent that, I’d recommend one (or both) of two solutions:

    1. store the user’s IP address in the session
    2. use session_regenerate_id() after every successful login attempt.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are some HTML based games (ie bootleggers.us) that have a simple login form
I am creating a PHP based web application which requires simple authentication to use.
I would like to know of a simple banner management system php based -
We use a simple object model for our low level networking code at work
I want to use the php simple HTML DOM parser to grab the image,
I'm looking for something simple to use where the grammar is easy to define.
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
My use case is very simple : I have a GUI application, and inside
Simple as the title states: Can you use only Java commands to take a
Simple question really - how do I use text_field_with_auto_complete inside a form_for block? I've

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.