There's a couple things you should know about cookies first.
- Where they are located
- How to copy your cookies
- What is in a cookie
- What can you do with cookies (other than eat them)
1. Where Are They Located
Depending on the internet browser you have, your cookies are stored in different places. I'm only going to look at Internet Explorer and Mozilla Firefox.
- Internet Explorer - %userprofile%\Cookies
- Mozilla Firefox - %appdata%\Mozilla\Firefox\Profiles\[random number].default\cookies.txt
EDIT: For Windows Vista with IE7, the cookies you can actually access are stored in a different location. They are in '%appdata%\Microsoft\Windows\Cookies'.
2. Copy Your Cookies
On Firefox, this is pretty simple. Just copy that 'cookies.txt' file and you're done. On IE, there are two ways. The easy way is to (this is using IE6) do File->Import and Export->Export Cookies and save the file. That will give you a cookies.txt file just like Firefox! If you want to copy to IE, just Import Cookies instead and pick the cookies file.
OK, so this wouldn't be an article without the hard and sneakier way. I started off learning the easy way before I wondered what else you could do if you just had the cookies folder. You start off by copying the 'Cookies' folder to a directory of your choice. If you try to paste this folder into some other another computer/user's folder, you find out a file called 'index.dat' can't be written! One solution to this is to logoff, and login as another user and then paste (to the first user). Ok, ok, that's a bit too annoying if you need to do that everytime. Before I teach the other way, there's some other stuff you should learn... (scroll to the bottom if you just want to know how)
3. What's in a Cookie
So you're looking at that exported cookie file from IE and wondering what the hell do all those numbers and other things mean. Here's the breakdown of all that stuff.
yahoo.com TRUE / FALSE 2127949143 C mg=1
- domain yahoo.com- what (the domain that) created the cookie
- flag TRUE- whether or not all machines in the domain can access this
- path /- place within the domain that has access
- secure FALSE- whether or not a secure connection is needed
- expiration 2127949143- when the cookie expires in epoch time (seconds since Jan. 1, 1970 00:00:00 GMT)
- name C- name of the cookie
- value mg=1- value of the cookie
4. What Can You Do With Cookies
The basics of what cookies are used for: shopping carts, tracking you (in good and bad ways), storing login information (for email, blogs, other websites), and a bunch of other stuff. You can copy your cookies if you're migrating from one internet browser to another.
Let's get back to copying then. Either just copy the folder, or create a .bat file to automate this. Just have:
'xcopy "%userprofile%\Cookies" "[destination]" \h \s \e'in the file (where [destination] is replaced with the destination folder. So you've copied the Cookies folder (maybe even "sneakily" using the .bat file). How do you make a 'cookies.txt' file to use on another computer?
There's a freeware utility called IECookiesView (download) that will let you do this. Open IECV and go to File->'Select Cookies Folder' and find where you copied the cookies to.
Select all the cookies (Ctrl+A or Edit->'Select All Items') and then File->'Export to Netscape/Mozilla File'.
At first I thought this was all and tried to import using IE. Didn't work. So what was wrong? Two things: the file is exported with a different newline character (uses Unix LF carriage instead of Windows CRLF) and instead of using regular text in the files, it uses percent-encoding (which is just used in URLs..see the wiki).
Fix the first problem by downloading and installing Unix2Win (download), right-clicking the exported file from IECV and selecting 'Text Converter'->Unix2Windows. Cool..that was fairly easy.
EDIT: Alright, so I went back and found out you don't need to install Unix2Win. If you use my converter (see below), it will take care of everything. It will fix the newlines and the percent-encoding problem.
The next problem is a bit harder. Convert the the percent-encoded file to a normal text file. You can find an online solution or use mine. I made my own converter using Java (download). You have to use it from command prompt. Use 'java URL2UTF8 input output'. Perhaps you don't trust this file? If anyone wants to compile it on their own, I'll post up the source code too. If there are any errors that I haven't handled properly, please let me know. Ok, so maybe that wasn't hard for you either (it was for me...I tried searching on the web with no good results before I made it on my own).
Great, now you have the correct cookie text file and it actually works on IE (and Firefox too)!
No comments:
Post a Comment