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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:45:40+00:00 2026-06-03T16:45:40+00:00

I am trying to reset the session cookie, and its life, when the user

  • 0

I am trying to reset the session cookie, and its life, when the user logs in in PHP.
It sounds pretty trivial but I am still struggling to make it right.

When the page is loaded, the user may or may not alreay have a cookie. If he has one, I want to delete it and reset the sessionId, if not I will just give him a new one with the proper life. I cannot use session_status() because of the PHP version I am using.

Here is what I came up with but it does not work when the user already has a session cookie.

if (isset($_COOKIE[session_name()])) setcookie(session_name(), false);
session_set_cookie_params(2678400); // sets cookie life to one month
session_start();
// do stuff

When the user is logged in, the old cookie is normally deleted but session_start() does not deliver a new cookie. It there a way to force delivering a new cookie without having to manually implement the logic of session id creation?

Thanks a lot for your help

  • 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-03T16:45:41+00:00Added an answer on June 3, 2026 at 4:45 pm

    You don’t have to destroy/restart the session on the PHP side, you just have to send a new cookie to the client. Just call setcookie() again (with the existing session id), that should do the trick.

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

Sidebar

Related Questions

I am trying to reset an asp.net session with ajax, but it's not working.
How I stop Jackrabbit using SimpleSecurityManager? I'm trying to call session.getUserManager() but I get
im trying to send rest api Users.getLoggedInUser i have all the secret session and
I am trying to reset the actual value attribute of an input so that
I'm trying to reset some input text fields, inside of a data table, using
I am trying to reset an array of JLabels. There are images on the
I have 2 dropdown lists on my webform and using jquery trying to filter/reset
I'm working on a password reset function and trying to check to make sure
So trying to create a rest service but I keep getting an error: If
I have these form values I'm trying capture in a session: prop_zip prop_st address

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.