You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement authentication by storing the logged in user's session id into a cookie. If a user is present with the session cookie, then this user is authenticated. If there isn’t a valid cookie present, then we aren’t currently authenticated. We can store additional data into the session as needed, such as the user’s set of permissions or anything else that is potentially useful. Typically session IDs are transmitted by header, or by injecting them into the URL.
Create database
CREATEDATABASEtesting;
Create tables needed in the Database;
CREATETABLE `users` (`id`int(11) NOT NULL AUTO_INCREMENT,
`username`varchar(255) NOT NULL,
`password`varchar(255) NOT NULL,
`email`varchar(255) NOT NULL,
`first_name`varchar(255) NOT NULL,
`last_name`varchar(255) NOT NULL,
PRIMARY KEY (`id`));
CREATETABLE `web_sessions` (`id`int(11) NOT NULL AUTO_INCREMENT,
`user_name`varchar(255) NOT NULL,
`session_id`varchar(255) NOT NULL,
`date_created`varchar(255) NOT NULL,
PRIMARY KEY (`id`));
Create database user
CREATEUSER 'dev'@'%' IDENTIFIED WITH sha256_password BY 'password';
CREATEUSER 'dev'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON testing.* TO 'dev'@'%';
FLUSH PRIVILEGES;