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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:28:43+00:00 2026-06-13T17:28:43+00:00

How do you make a SESSION cookie last for longer? I’m using this code

  • 0

How do you make a SESSION cookie last for longer?

I’m using this code in the file that logs in my users:

<?
session_regenerate_id();
session_set_cookie_params(3600*24*365);
session_start();
$_SESSION['u']['id'] = xxxx;
?>

And on the rest of the site I use only session_start(); to start the session.

The cookie PHPSESSID on the client is set to expire in 365 days but if I don’t use the site for a day and come back I’m logged off. Do I have to do something else to make the cookie last longer?

  • 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-13T17:28:44+00:00Added an answer on June 13, 2026 at 5:28 pm

    In normal cookies, you can do this manually while setting the cookie:

    setcookie($foo, $bar, time()+(3600*24*365));
    

    However, session cookies are AUTOMAGICALLY deleted after your browser is closed (unless you are using a browser that specifically saves your sessions across runs). To be honest, if you want sessions to last longer than, well, a session, you should serialize said session with some kind of data persistence, like MySQL.

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

Sidebar

Related Questions

I want to make my session cookie HttpOnly . Based on this article ,
I put this on my index file: session_set_cookie_params(31536000); session_start(); It keeps users logged in
I need to make a Function that receives a Session Key and a Session
i make one class file for jar. and this class have use wurfl. and
I use authkit module with Pylons and I see that session cookie it sets
I am writing forum app on Django using custom session/auth/users/acl system. One of goals
How can I make the connect.sid cookie itself only a session cookie instead of
I'm doing it like this: app.use(express.session({ cookie:{domain:.+settings.c.SITE_DOMAIN}, secret:'abc', store: redis_store, })); When I log
I can't seem to make any progress with this one. My CI session settings
http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime says that a session.cookie_lifetime of 0 goes until the browser is closed. Is

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.