|
-
December 4th, 2003, 07:37 AM
#5
Okay lets go a step furthur.
A cookie is a small piece of information that a website can download and store on your computer. The cookie itself gets sent out with the HTTP headers of a website. The header's syntax is as follows:
Set-Cookie: NAME=VALUE; [expires=DATE;] [path=PATH;] [domain=DOMAIN_NAME;] [secure]
When this is called via a HTTP header, it will create a cookie called NAME with a value of VALUE. All the other stuff in braces is optional.
- expires: This sets an expiration date that the cookie will expire and no longer be valid. If no expiration date is set, the cookie stays till you or the user manually deletes it.
- path: The url that the cookie is valid for.
- domain: The domain the cookie is valid for.
- secure: This flag means that it will not be sent over a plain http connection.
Now each time the user visits the site, you will have to look for this cookie by using some type of programming. I use PHP personally, but many other languages can create cookies.
To create a cookie in PHP you use the setcookie() function.
bool setcookie ( string name [, string value [, int expire [, string path [, string domain [, int secure]]]]])
PHP Code:
setcookie('cookiename', 'data');
Thats basically it. You can now call the cookie each time a visitor visits a site by doing this.
PHP Code:
$HTTP_COOKIE_VARS['cookiename'];
Thats all there really is to cookies. Now its up to you to figure out what you can do with them.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|