Click here to Skip to main content
15,893,644 members
Home / Discussions / Database
   

Database

 
AnswerRe: cookies vs sessions for storing users id for ecommerce site Pin
Afzaal Ahmad Zeeshan3-Aug-19 4:02
professionalAfzaal Ahmad Zeeshan3-Aug-19 4:02 
Let's discuss this in a bit proper detail with the application of performance, security and regulations.

You can store anything that is publicly available on your website, and does not contain any personal or identifying information in a cookie. The reason for this is, that a user might be accessing your website from a public machine or PC and that data might be tracked or stored. Next, for a session you can use this storage to store any information that might identify (because, hey, that is what a session is about, right?) the user and help your website perform an operation quickly—without having to query the database again just to find out their user id, or email address. Do remember that on most frameworks (if not all), session data is sent to the client too.

Now as per regulations, make sure you are requesting permissions from the users to store the cookies on their machines—European regulations require you do that, and then there is GDPR, and etc. etc.

Now as for the database part, this space is expensive and filling it with the content that does not help you in anyway—let us for a moment ignore the analytics, user studies, machine learning for recommender systems, etc.—and they will only take away the space that you should pay for the content that helps you generate some business profits.

What I would recommend here is, store the cart information in the cookies, just reference the URLs of the items they want to purchase. This way, the cart information will be stored locally. This will decrease the overall load on your web servers, and will not cause extra charges in the database storage as well since your users will be storing their interests locally and won't add a cart option in database, and forget it leaving there forever.

One tip I can provide here is to use localStorage APIs, instead of cookies, because cookies also have a round trip from and back to server, adding an overhead on the HTTP request.

Window.localStorage - Web APIs | MDN

In this approach, of course you will end up showing what John wanted to purchase to Johanna as well, and that can be fixed by storing the session id(! Remember, store only the session id not the user id and then verify that the sessions are same for the user—which can be done by some backend algorithm to check if user ids of the sessions are the same Laugh | :laugh: )
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~

QuestionI didn't design it but I need to get data out of it. Pin
rnbergren2-Aug-19 4:23
rnbergren2-Aug-19 4:23 
AnswerRe: I didn't design it but I need to get data out of it. Pin
Richard Deeming2-Aug-19 4:51
mveRichard Deeming2-Aug-19 4:51 
GeneralRe: I didn't design it but I need to get data out of it. Pin
rnbergren2-Aug-19 8:12
rnbergren2-Aug-19 8:12 
AnswerRe: I didn't design it but I need to get data out of it. Pin
ZurdoDev2-Aug-19 10:33
professionalZurdoDev2-Aug-19 10:33 
AnswerRe: I didn't design it but I need to get data out of it. Pin
Mycroft Holmes2-Aug-19 13:40
professionalMycroft Holmes2-Aug-19 13:40 
QuestionSQL Server: Facing problem to parse xml using xquery Pin
Mou_kol31-Jul-19 5:56
Mou_kol31-Jul-19 5:56 
Questionstructure question 2 Pin
Joan M18-Jul-19 21:25
professionalJoan M18-Jul-19 21:25 
AnswerRe: structure question 2 Pin
Richard Deeming19-Jul-19 1:11
mveRichard Deeming19-Jul-19 1:11 
GeneralRe: structure question 2 Pin
Joan M19-Jul-19 1:14
professionalJoan M19-Jul-19 1:14 
GeneralRe: structure question 2 Pin
Richard Deeming19-Jul-19 1:27
mveRichard Deeming19-Jul-19 1:27 
PraiseRe: structure question 2 Pin
Joan M19-Jul-19 1:31
professionalJoan M19-Jul-19 1:31 
QuestionBest practices for database tables. Pin
RLD7114-Jul-19 12:37
professionalRLD7114-Jul-19 12:37 
AnswerRe: Best practices for database tables. Pin
CHill6017-Jul-19 23:17
mveCHill6017-Jul-19 23:17 
AnswerRe: Best practices for database tables. Pin
Mycroft Holmes18-Jul-19 11:57
professionalMycroft Holmes18-Jul-19 11:57 
GeneralRe: Best practices for database tables. Pin
RLD7121-Jul-19 3:37
professionalRLD7121-Jul-19 3:37 
Questionstructure question Pin
Joan M11-Jul-19 1:30
professionalJoan M11-Jul-19 1:30 
AnswerRe: structure question Pin
Eddy Vluggen11-Jul-19 2:01
professionalEddy Vluggen11-Jul-19 2:01 
GeneralRe: structure question Pin
CHill6018-Jul-19 1:30
mveCHill6018-Jul-19 1:30 
GeneralRe: structure question Pin
Eddy Vluggen18-Jul-19 22:53
professionalEddy Vluggen18-Jul-19 22:53 
QuestionQuery numbering in groups in access database ? Pin
Member 24584674-Jul-19 23:50
Member 24584674-Jul-19 23:50 
SuggestionRe: Query numbering in groups in access database ? Pin
CHill6010-Jul-19 7:51
mveCHill6010-Jul-19 7:51 
GeneralRe: Query numbering in groups in access database ? Pin
Member 245846710-Jul-19 17:57
Member 245846710-Jul-19 17:57 
GeneralRe: Query numbering in groups in access database ? Pin
CHill6010-Jul-19 21:38
mveCHill6010-Jul-19 21:38 
QuestionHow To Fix SQL Database Error 824 ? Pin
Member 24584673-Jul-19 22:10
Member 24584673-Jul-19 22:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.