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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:32:39+00:00 2026-06-08T04:32:39+00:00

When the user registers an account, a table is created with columns; userid and

  • 0

When the user registers an account, a table is created with columns; userid and token. This is because if the user checks remember me when logging in on different computers, each computer has a different token.

register.php

//user specific table created    
$create = $connectdb->prepare("CREATE TABLE `user-:username` (userid INT, token varchar(200)");
                        $executequery = $create->execute(array("username"=>$username)); 

Here is a snippet of login.php; I create the token, store the token in a cookie and insert the token to that user specific table

  if($remember==1) {
                            $token = md5(uniqid('',true));
                            setcookie('token',$token,time()+60*60*24*365);

                            $rememberquery = $connectdb->prepare("INSERT INTO `user-:username` VALUES ('',:username,:token)");
                            $rememberquery->execute(array(":username"=>$username,":token"=>$token));
$_SESSION['username'][0] = $username;       
$_SESSION['username'][1] = $userid;                 
                            }

Now i’m stuck(assuming i have done the previous correctly). When/How do i check the cookie token to the database token?

  • 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-08T04:32:41+00:00Added an answer on June 8, 2026 at 4:32 am

    Proper authentication is hard to do correctly so, you have to play a little hacker from time to time in order to get things mostly right. First of all, you should read Session Management Cheat Sheet and owasp page in general.

    After this lecture you should know the dos and donts of session management. But if you need a remember me cheat sheet 😉 it should go like this:

    • Value should be either completely random, or cryptographically strong(which can be tricky)
    • Should be validated upon recive
    • Never ever ever trust in what you get in a cookie, so storing username in a cookie is a very very very bad idea, if it is not followed by proper validation
    • If session expires create new one, populate it with data from your table, and voila,
    • If you need to persist something, use database not a cookie cookies are bad and not trustworthy 😉

    Also a fine publication is by microsoft Threats and countermeasures , it can help you a lot.

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

Sidebar

Related Questions

This is the standard scenario: User registers on the site User receives an account
When my user registers in Drupal and his account is created, I'd like to
I have a script that registers users based on their user input. This uses
I created this account registration activation script of my own, I have checked it
When a user registers an account, I issue a verification code that is later
TL;DR I want to check my Coupon table when a new user registers to
When a user registers, the script sends an email to verify his account. Clicking
I have a user registration Form. If a new User register their account in
Say a user registers for your site, you hash the password they have chosen
When a user registers with my site I want to offer them a login

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.