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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:28:58+00:00 2026-06-01T01:28:58+00:00

I am developing an application and I’d like to offer the user a possibility

  • 0

I am developing an application and I’d like to offer the user a possibility to stay signed in forever. If he checks a box, his session should never end, unless he manually logs out or deletes the cookie. If he doesn’t, his session cookie will expire on closing the browser.

I considered three ways to realise this, but all of them contain pros and cons:

  • Saving a cookie with the user name and his hashed password:
    • Pro: The user can have multiple active sessions on different devices.
    • Con: If the cookie gets leaked by third parties, they can regenerate his session at any time unless he changes his password.
  • Generating a token which will be stored in the database and in the user’s cookies. Then compare them:
    • Pro: As soon as the user logs out, the token will be randomized and all of his sessions will be destroyed. He will definitely be logged of.
    • Con: The user can only log in forever with one device. As soon as he logs in from another device, accepting to be logged in forever, his other token will be overwritten.
  • Only hypothetically: Save sessions forever on the server and give non-expiring cookies to the user.
    • Con: This is probably not realistic, because you can’t store that much data in an efficient way.

I currently prefer the second way, because it does not seem to be as insecure as the first one and it’s easily implementable. But I am still not convinced of it and I have seen that there are proven frameworks which do it another way.

Could you imagine another way which is maybe even better? What’s your favorite and why?

  • 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-01T01:28:59+00:00Added an answer on June 1, 2026 at 1:28 am

    Never save the password in a cookie. The second method is fine, and is how I think you’ll find most apps implement this feature. Note that the session storage doesn’t need to be a database. The cookie contains some unique (unguessable!) id, and this id points to some unique storage. It could be a text file in a directory somewhere, a database row, a JSON string in memcached, whatever.

    Pro: As soon as the user logs out, the token will be randomized and
    all of his sessions will be destroyed. He will definitely be logged
    of.

    Con: The user can only log in forever with one device. As soon as
    he logs in from another device, accepting to be logged in forever,
    his other token will be overwritten.

    Don’t store the token id as a column in the user table. Instead create a new cross table that allows more than one session per user. So, each device will have its own separate token, and thus, its own separate session which can be managed individually.

    When a user logs out, you destroy only that one cookie and its associated session store. Any other sessions that the user has outstanding will remain untouched.

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

Sidebar

Related Questions

I developing application which using geo-location. Should i ask user right for this when
I'm developing application with GWT 2 and would like to add float panel that
I am developing application having a resemblance appearance like Gallery application. When I click
I am developing Application in android I want to show AlertDialog if user check
I have heard that when developing application which uses a database you should do
I’m developing application with JBoss AS 5 with a special configuration according to my
I'm developing application that can be useful only in my country(Ukraine). In Ukraine people
I am developing application which is having Gujarati font in text-view but my problem
I'm developing application using backbone.js & jquery. I have following code in model: runReport:
I am developing application on Images. In that if I click on same image

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.