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

  • Home
  • SEARCH
  • 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 8160339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:11:43+00:00 2026-06-06T18:11:43+00:00

When a user selects the remember me function, I save his username and id

  • 0

When a user selects the remember me function, I save his username and id in a cookie. Then, when the user returns to the site, I check the username and id against a database to ensure that the user is legitimate. I next log the user in by storing the cookie data in the session variable. Is this the proper way to remember and log in a user?

  • 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-06T18:11:44+00:00Added an answer on June 6, 2026 at 6:11 pm

    Cookies are not a very secure way of storing data. The cookies can be modified by a user and could lead to someone “hacking” into your site. What I would suggest is store a string in the cookie that is some hash of something. Also store the hashed string from the cookie in your database. This way when a user returns to the site, you check to see if the cookie is filled, match it to the hashed value in the database and then find who owns that hashed value. If all is valid, log them in.

    Database setup

    secretKey PK varchar
    userid (could be unique) int
    validUntil int or date/time
      //If userID is unique you will have to remove this row from the 
      // database when a new key is made for the user,  This would then mean
      // that a user would only be allowed to be rememberd on one computer
    

    pseudocode

    //User logs in with remember me
        //set cookie to something like md5(userid,username,timestamp)
        //store the md5 in the database layout
    //User Returns to site
        //check to see if cookie is set
            //if cookie set
                //find md5 in database which is logged with user id
                //if found and not yet expired log in
                //else show login page
            //if cookie not set show login page
    

    In the valid until field you would set it to say 2 weeks from login. once the valid until has passed, do not let that key work and make sure the cookie is expired for the user.

    query to check login

    SELECT * FROM rememberMe WHERE key=”//put md5 here” AND validUntil > time()

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

Sidebar

Related Questions

Let's say a user from a global site selects his/her country from a drop
The user selects a state from a drop-down field, then ajax posts that value
Suppose a user selects a file in a dialogue box, and the app then
If a user logs in and selects Remember me for 2 weeks, I want
I want to save password when user select remember me checkbox. I have code
A user selects a portion of an image for a cut and paste operation.
When a user selects a file, I want another file field to appear. It
Background story: when a user selects a portion of text in a text field
When a user selects an item to delete, I open an alertDialog to make
I have button that a user selects and I pop up a AlertDialog to

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.