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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:28:51+00:00 2026-05-18T23:28:51+00:00

So this is basically a reassurance that I’m doing the whole registration/login process right

  • 0

So this is basically a reassurance that I’m doing the whole registration/login process right as far as hashing/salting goes.

I have a users table with the fields password, salt, token (obviously there are others but this is the most important). Upon registration it generate a random salt, and a random token, and it puts in the password field this:

hash("sha256", $theirpostpassword.$randomgeneratedsalt);

That random generated salt and token are stored in their respective fields in that users row in the table.

So upon login I select the salt ONLY from the users row with the username they specified. I then do a count query of how many rows have their post password concatenated with their specific salt, and then I log them in. Pretty sure I have that part down.

Now I was thinking to validate their login on every page I would have a function ran every page that checks their cookie to see if the format of id-username-token matches the row in the database. Meaning that every login it sets their cookie with those credentials.

Now the only thing I can think of to make it better is change the token every valid login?

Thanks for the insight guys.

  • 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-18T23:28:52+00:00Added an answer on May 18, 2026 at 11:28 pm

    Yes, you should definitely be changing tokens with every login. Otherwise a token stolen once is an account stolen forever. Users expect that logging off secures their session from attack by invalidating their cookies or other data.

    Rather than the token being random, you can make it serve as a signature, by generating it from a hash of the user id, session expiry time, and whatever else you want in the cookie, plus a salt (just like the login system). This salt doesn’t have to come from the database, but it can. It could be a hardcoded string (sometimes called a “pepper” I think). Remember to treat the cookie as invalid if it’s past the expiry time. That’s why the token should be a signature, to make sure they didn’t spoof that data.

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

Sidebar

Related Questions

What are the different types of encapsulation? Am I right in thinking this basically
I know that in C#, if you write ~MyClass() , this basically translates to
So, since the answer to this basically said that I really should look into
Basically I have run-time loaded class that looks like this: [Plugin(Plugin name)] class PluginActions
I am trying to to build a Felix bundle in Eclipse. This basically includes
This code basically translates characters based on position in one string to the character
This is basically a math problem, but very programing related: if I have 1
This is basically a duplicate of this question , but the accepted answer was
This is basically the same question as Click items in select box, and then
This is basically a 'best practices' question. Struts 1 forms have getters and setters

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.