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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:17:03+00:00 2026-05-27T16:17:03+00:00

I had a quick question about cookie security that I wanted to run by

  • 0

I had a quick question about cookie security that I wanted to run by the stackoverflow community before I got too far into implementing it. This will be my first time implementing user sign-in on a site and I wanted to be extremely cautious about security so-as not to have to worry about accounts being compromised down the line.

Here’s my hypothetical security solution:

  • User signs up for site (through either email registration, login with Facebook, etc.) and is assigned a User ID number. This number is public and can be used to access the profile of the user, refer to them in posts, and so on.
  • At registration, the user is also assigned a randomly generated ROWID as their information is stored in a database (hosted on Google Fusion Tables). This ROWID number is kept hidden from the user and is never revealed.
  • The User ID is encrypted against the ROWID number and this number is stored in a cookie on the user’s computer. It isn’t ever visible to other users and, in theory, this could only be viewed by the user.

This solution would allow for a “secret” key (the ROWID number), a “consumer” key (saved in the cookie), and a public reference ID (the User ID). All of these are, of course, rolled up into a database where the site can quickly access them. Does this sound like a plan that would provide the proper level of security or is there something else that I should consider?

  • 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-27T16:17:04+00:00Added an answer on May 27, 2026 at 4:17 pm

    For additional protection against cookie theft through something like XSS, you might want to consider issuing unique cookies per IP address, and then making sure that the cookies are only useable from that IP address.
    If you’re storing your cookies in the database, things can get complicated, as you now have multiple cookies mapping to the same user.

    Here’s how to avoid those problems:

    Set-Cookie: userName=Alice; authCode=eeba95a4...
    

    Where: authCode=HMAC(ROWID, userName + ipAddr)

    When you receive this cookie, look up the user in the database, recompute/verify the authCode in the cookie, using ROWID and ip address of the request. No need to store cookies in the database.

    For extra crypto points, throw a salt parameter into the mix:

    Set-Cookie: userName=Alice; salt=59843...; authCode=eeba9...
    

    Where: authCode=HMAC(ROWID, userName + ipAddr + salt)

    Salt value is generated randomly for every cookie you produce. There’s no need to keep it a secret.

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

Sidebar

Related Questions

I had a quick question about Django URL configuration, and I guess REGEX as
I just had a quick question about git - how backwards compatible are git
Had a quick question about Sphinx Search installation. Do I need to install it
Folks, I had a quick question about Amazon EC2, I have been recently using
Had a quick question about joins in mysql and indexing. If I had 2
Quick question about JSON in general, say I had: var foo = { a:
Just have a quick question about the GAC I created an assembly Awesome.DLL. Had
I had a quick question that's been bugging me. I'd like to place a
Hey everyone, I had a quick question that should be easy for someone who
I just had a quick question about how stack variables versus heap variables work.

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.