Clarification
by res09ojz - 2/21/12 7:54 AM
In Reply to: corroboration? by ckollars
Jennifer Kyrnin, About.com
(Posted without her permission out of context)
What Cookies Can Store
Cookies can store the following types of information:
Your Web browser and version
Your operating system
Your IP address (and from that possibly a close approximation of where you are browsing from)
The date and time
What page was visited using that browser and OS
A unique ID that the website generates for you the first time your browser arrives
Any information you provide via forms on the website
The credit card companies know your name, what you purchased, what store you were at, how much you spent, what your credit limit is, and more.
While cookies can store that information, they can't store it if you
don't provide it to the website.
Cookies Do Not Endanger Files on Your Hard Drive
Cookies are little text files (or lines in a text file) that are stored on your hard drive. They cannot execute code or act as a virus or malware.
A cookie is a line of text that looks something like this:
.about.com TRUE / FALSE 1692181505 jsc 13
In essence, this says that the cookie named jsc is served from anywhere on the .about.com domain.
It has a value of 13 and expires on June 9, 2028 at 10:47:06PM.
No, I don't know how About.com is using this cookie, but honestly, I don't care. The most damage that this cookie could do to me is fill up needed space on my hard drive. And it's easy to delete them if I have that problem.
Privacy and Cookies
If you're concerned about privacy issues with cookies, you would be better off finding out the privacy policies of the sites you visit.
The only way a cookie can store private information is if you give it to the site.
This could be through filling out a form, buying something, or joining a chat or forum on the site.
If you don't want your private information to show up in a cookie, then you shouldn't put it in a web form.
A site has access to any information you provide without using any cookies at all. Thus, it's more important to know the privacy policies of a site than to worry about whether they use cookies.
Create a Cookie
Cookies are set by the browser, often with a CGI or JavaScript. You can write a script to set a cookie at any
event on a Web page. For example, if you go to this page you will be given the option to set a cookie when
you click another link. The cookie looks something like this:
Set-Cookie: Count=1; expires=Wednesday, 01-Aug-2040 08:00:00 GMT; path=/
This means:
Set-Cookie:
This is the call that set's the cookie in the browser's cookie store.
Count=1;
This is the name of your cookie.
expires=Wednesday, 01-Aug-2040 08:00:00 GMT;
This details when the cookie will expire.
path=/;
This is the minimum path that needs to exist for the cookie to be returned.
WhoamI.com
The domain that set the cookie, and is the only domain that can retrieve the cookie.
Write the Cookie with JavaScript
Use the following code to write your cookie:
<script language="JavaScript">
cookie_name = "Basic_Cookie";
function write_cookie() {
if(document.cookie) {
index = document.cookie.indexOf(cookie_name);
} else {
index = -1;
}
if (index == -1) {
document.cookie=cookie_name+"=1; expires=Wednesday, 01-Aug-2040 08:00:00 GMT";
} else {
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
count = eval(document.cookie.substring(countbegin, countend)) + 1;
document.cookie=cookie_name+"="+count+"; expires=Wednesday, 01-Aug-2040 08:00:00 GMT";
}
}
</script>Read Your Cookie
Once you've written the cookie, you need to read it in order to use it. Use this script to read your cookie:
<script language="JavaScript">
function gettimes() {
if(document.cookie) {
index = document.cookie.indexOf(cookie_name);
if (index != -1) {
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
count = document.cookie.substring(countbegin, countend);
if (count == 1) {
return (count+" time");
} else {
return (count+" times");
}
}
}
return ("0 times");
}
</script>Call Your Cookie in a Link
Set your cookie when someone clicks a link with this code in your HTML body:
<script language="javascript">document.write(gettimes());</script>
Now everyone can create an read their own cookie and make a determination for themselves
Was this reply helpful? (2) (0)
Staff pick