Page 1 of 1

How to set cookies first and then store that in a database?

Posted: Tue Dec 29, 2009 5:58 am
by indian98476
i want to set cookies for users logging in so that i can give them back personalised webpages.,...i heard we must create the cookies and then store them in a database....can anyone code me into it?

Re: How to set cookies first and then store that in a database?

Posted: Tue Dec 29, 2009 7:40 am
by Apollo
Cookies are, by definition, stored in the visitors' browser. Not in a database.

See also

Re: How to set cookies first and then store that in a database?

Posted: Tue Dec 29, 2009 11:26 pm
by indian98476
so here is my doubt now..
i got say 3 users a,b and c...when anyone logs in for the first time he should get a msg lets say Welcome to our site...
if the same user logs in again he should get a msg lets say welcome back
user's name

if a different user logs in the same browser he should get a msg lets say Welcome to our site
if the user who logged in first again logs in after this he should get welcome back
user's name

so if the first user's value is stored in d browser what bout the value of the next user?
i think u r getting my doubt...if not feel free to ask...

Re: How to set cookies first and then store that in a database?

Posted: Wed Dec 30, 2009 6:11 am
by Apollo
But that's not something I'd do with cookies. Instead, simply store on your server (in a database, for example) which users have already logged in before.

So if someone logs in, you get the 'has_logged_in_before' value for the given username from your database, and display the appropriate welcome message. No need for cookies at all. Works also if someone clears his browser or logs in from another computer.

Re: How to set cookies first and then store that in a database?

Posted: Wed Dec 30, 2009 11:09 pm
by indian98476
thanx appollo...i thought cookies were the ones that helped the user give suggestions on the textfield if he has come before for his username...but i learned that it is the work of browser...but how exactly does it do it?

Re: How to set cookies first and then store that in a database?

Posted: Thu Dec 31, 2009 8:00 am
by Apollo
It simply remembers the strings that the user has filled in before in fields called "name", "email", etc.
A bit like caching.