new to cookie: concept

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php12342005
Forum Commoner
Posts: 79
Joined: Mon Mar 21, 2005 3:35 am

new to cookie: concept

Post by php12342005 »

hi all,
let me start with netscape as example.
when we try to login again in netscape to some place we logined before, netscape can show our user name and password automatically.

ok, my questions:
1. does netscape set user name and password as cookie's value?
or
2. does netscape use the cookie's value as ID to its server's database to read user name and password?

I guess 1 is right anwser, but it is possible that people use 2 also for cookie.

what value do you set for cookie?

(may be an advanced question)
3. why netscape can auto input user name and password in related controls? how does netscape know which control is used for user name or password?

thanks
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Cookies allow you to save information on a visitors PC... Sessions allow you to save information in a database on the server and retrieve it.

Cookies = teh suck because there's a large percentage of users who block all cookies (Yay for false security!)

Netscape is dead ^_^;; The new wave is Firefox, same technology pretty much, but better...

Edit: Just for clarification: Netscape doesn't know <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>. It's what you tell it, that it knows. If you want it to know a password, you have to code something to signify a password. (I'd assume, unless if Netscape is a bloody psycic)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

php12342005 wrote:when we try to login again in netscape to some place we logined before, netscape can show our user name and password automatically.
Incorrect.

By default, once you login, it will ask if you want it to save your login. If you say yes, then it will save both. If you say no, it will save just the username.
php12342005 wrote:1. does netscape set user name and password as cookie's value?
Not to accomplish the above, no. It saves them in your profile information.
php12342005 wrote:2. does netscape use the cookie's value as ID to its server's database to read user name and password?
Definitely not.
php12342005 wrote:why netscape can auto input user name and password in related controls
Because you told it to, so it saves them per your request.
php12342005 wrote:how does netscape know which control is used for user name or password?
Actually, the trick is that it doesn't.

For passwords, its easy, because its input type *IS* password, so it knows as soon as it displays it.

However, on pages with multiple password forms, it will store all of them - because it doesn't know.

Username however is even less clear - any textbox input it will save if you request it to.

My understanding is that this behavior changed in the current NS, which is based off of Gecko (the engine powering Firefox as well). In NS7+, it stores only one pw and username per form, and takes a best guess about which they are using the field names. (I may be wrong about that).

Cookies have nothing to do with the browser autocompleting your login information.

And as a side note, for all the cookie-hating, session-fanatics.. sessions use cookies too unless they are passed in the url. Cookies aren't the problem, long-life cookies and marketing are. :)
Post Reply