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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:58:53+00:00 2026-06-11T15:58:53+00:00

I am aware that you might be thinking " Do not store user’s credentials,

  • 0

I am aware that you might be thinking "Do not store user’s credentials, hash them with salt+pepper you idiot!", but please read on.

I’m working on a project that is going to ask the user about the credentials (login/password) for its database. Those credentials will be tried against the database, and if the connexion is successful, I will "keep" them for doing some work on the database as asked by the user (create a table, change a row, do a SELECT, etc).

That means, every time the user will do something, I will reconnect to the database before doing his request => I can’t hash the credentials because they will be useless for the subsequent requests. It’s like phpMyAdmin, if you like.

So I came up with various possibilities, but each of them has flaws. I’m looking for suggestions to determine which one would be better.

  1. Just use a Session cookie with login/password in clear. But allow only the use over HTTPS : This on is the most simple way to implement. The only drawback I see is if there is a XSS on the client side, the credentials can be retrieved.
  2. The same session cookie, but with encrypted login/password using AES. It’s what it is used by PhpMyAdmin I believe. I can go further by only allowing HTTPS too.
  3. Store the credential in clear in a local session storage (session.db in sqlite), and use a Token for the client that will be retrieve using the given token + browser details. Drawback : If an attacker access the session.db file, he will be able to read the sessions that haven’t been removed from the file. I don’t think encrypting them will be useful, since if he can access the session.db, he can certainly also access the SECRET_KEY used to encrypt them.

What do you think? What would you do?

  • 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-11T15:58:54+00:00Added an answer on June 11, 2026 at 3:58 pm

    I recommend against using 1. or 2., for the following reasons:

    • The credentials are useless for the client
    • Sending he credentials over the wire on every request (in whaever form) is not a good idea

    So what stays, is a variation on Version 3., store it in the session. This has one important property: If your session storage is not secure, this means, your server is not secure. Game over.

    To protect against an attack on session.db nonetheless, you could have a hardcoded key base in your app. This key base is salted with the session token and then hashed, the result is used as a key to en- and decrypt the client credentials. This way, an attacker would need to compromise the session.db AND your app (to get the key base). If he is able to do that, nothing will help you.

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

Sidebar

Related Questions

Disclaimer I am well aware that PHP might not have been the best choice
I am aware that MD5 hashes are not advisable for security any more but
I'm aware that map is not prepared to be sorted. It's heavily optimized for
I think this might be a classic question but I am not aware of
I aware that this will be a less programming question, but still... How can
I am aware that I can set null like string val = null; But
I'm aware that this is possible with the os module's os.system(color) function, but this
Now I'm aware that adding listeners, then setting fields would trigger the change. So
I am aware that I can access all external links on a page using
Now I am aware that I probably need to use a ListBox and can

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.