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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:04:26+00:00 2026-05-27T22:04:26+00:00

How do I securely store a user’s password in a cookie while still being

  • 0

How do I securely store a user’s password in a cookie while still being able to access that password? I’ve got a cookie that stores the username and sha1 version of the password but when I try to retrieve them I get the (as expected) username and the sha1 version of the password, and not the password itself. thx!

<!DOCTYPE html>
<html>
  <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
  </head>
<body>

<form id='my_login' name='my_login' action='<?php htmlentities($_SERVER['PHP_SELF'])?>' method='post' accept-charset='UTF-8'>
<input type='hidden' name='submitted' id='submitted' value='1'/>
 <label for='username'>Username: </label>
 <input id='username' type='text' name='username' value='<?php if(isset($_COOKIE['username'])) echo htmlentities($_COOKIE['username']); ?>'/>
 <br/>
 <label for='username'>Password: </label>
 <input id='password' type='password' name='password' value='<?php if(isset($_COOKIE['password'])) echo htmlentities($_COOKIE['password']); ?>'/>
 <br/>
  <label for "set_cookie">Remember Me</label>
 <input type="checkbox" name="set_cookie" id="set_cookie" value="1"/>
 <button id='submit' type='submit' name='submit'>login</button>
   </form>

  </body>
  <html>
  • 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-27T22:04:27+00:00Added an answer on May 27, 2026 at 10:04 pm

    How do I securely store a user’s password in a cookie

    Never store the user’s password locally. Even when using encryption that is considered secure at the moment, you are opening a huge potential security hole because you are spreading data for a possible attacker across lots and lots of client machines.

    Give the user a long-term cookie with a random session ID instead. Give that session an expiry time far in the future (storing it indefinitely is not a good idea. Many sites limit it to 30 days.) Have that ID log the user in automatically on your server.

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

Sidebar

Related Questions

I want to securely store a plaintext password on Windows PC. I am currently
The CruiseControl.Net tfs integration requires a username and password for a user with rather
I need to securely store private user data so it can persist across my
I have a Silverlight Business Application. I want to store the username and password
I wish to securely delete (not even a trace in memory) anything that user
If it is good style and security to store passwords securely and properly, then
What are some platform-specific API's that web browsers use to securely save passwords with
I would like to securely store a shared secret key on Windows but make
I'm building a system that need to collect some user sensitive data via secured
I have a situation that users access remote MySQL server in C# application. Basically,

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.