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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:10:31+00:00 2026-05-18T05:10:31+00:00

In my login script I have put a checkbox that people can check if

  • 0

In my login script I have put a checkbox that people can check if they want to be kept logged in. I have named the checkbox “stayin”.

Now, the problem is, that when a user comes directly to the index of the login page a session is already set (and it expires when the “session ends” – or rather when the browser is shut down). So, let’s say you’ve marked the “Keep me logged in” box, you browse the page, and then shut down the browser and went back — you would not still be logged in because setting the session lifetime did not work, because the session always gets set without a specific lifetime by the index script. Since not everyone wants to be logged in all the time, I can’t really set “session_set_cookie_parameters” to “never” expire before I make use of session_start() (which is why session_set_cookie_params is used in my script AFTER session_start() (I’m not sure this really works)).

So, for the index script, I simply use session_start(); and check if there’s a value for “Username” and redirect the user past the login.
And for the action script:

<?php
session_start();
if(isset($_POST['stayin'])){ // In case they want to be kept logged in.
session_set_cookie_params(999999999,"/path");
}
?>

I use session_start() at the very top of every script.
Using PHP version 4.4.9.

  • 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-18T05:10:32+00:00Added an answer on May 18, 2026 at 5:10 am

    AFAIK session_set_cookie_params() only modifies the session cookie length for the duration that the script is running (see http://www.php.net/manual/en/function.session-set-cookie-params.php). The only way to permanently change it is to modify the entry in the php.ini file, but this will change all sessions to have a long timeout which is not what you want either. Are using client-side cookies an option rather than using server-side sessions? If so you could set the lifespan of cookies individually with setcookie() based on whether the user has ticked the checkbox or not.

    <?php
    if(isset($_POST['stayin'])){ // In case they want to be kept logged in.
       setcookie('logincookie', true, 999999999, '/path');
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a login script that when successful, should check to see if the
I'm currently building my own login script and have noticed that most append the
I have a facebook login system that seems to work fine, but I want
I am using my admin panel login script where i have created a global.php
I have the following shell script registered in my Login Items preferences but it
I have php scripts that do things like register, login, upload. I would like
Following is my php login script, There are one problem. If i put any
I have a script that should log the user out of the site. It
I have a whole series of commands that I need to run on login,
I have quite a few simple functions that I had previously kept in my

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.