Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

VVP: Cookies - what is in them?

by vivekvp (Acolyte)
on Apr 24, 2002 at 21:13 UTC ( [id://161792]=perlquestion: print w/replies, xml ) Need Help??

vivekvp has asked for the wisdom of the Perl Monks concerning the following question:

Hello, Trying to figure out cookies. I would like to be able to look at the data in a cookie.

How do I look into a cookie? I am working on a web based app written in a databas language. Would I still be able to see the cookie it places with Perl? I am not even sure where cookies get stored so I can find them.

Also - cookies do not always have 'english' in them but data like %D0 - any way to translate that or know what it means?

Any one with any quick programs to view cookies?

Thanks,
V

He who laughs last, doesn't get the joke.

Replies are listed 'Best First'.
Re: VVP: Cookies - what is in them?
by andreychek (Parson) on Apr 24, 2002 at 23:20 UTC
    The previously mentioned ideas should work fine for you. However, to add to the variety, I have two other options for you to consider:

    1. Most browsers offer an option to prompt you before storing a cookie. In doing so, many of these browsers show you the contents of the cookie, along with how long the cookie will be valid for. With this method, you know for sure, immediatly, whether or not your application is properly setting cookies. You can easily enable this option by editing your browser preferences, and looking for the checkbox labeled something like "Ask me before storing a cookie".

    2. Some browsers offer a cookie manager, much in the same way that there is a bookmarks, or favorites manager. For instance, I know Mozilla 0.99 offers such a feature. In Mozilla, if you edit your preferences, and go into your privacy and security tab, click "Manage Stored Cookies", you can see all the settings for each cookie currently on your system.

    I wish you luck in using cookies within your application!
    -Eric
(cLive ;-) Re: VVP: Cookies - what is in them?
by cLive ;-) (Prior) on Apr 24, 2002 at 21:38 UTC
    Use the CGI module to read and set cookies. This module automatically decodes any hex (eg '%D0' values).

    Have a play with some code, and if you get stuck again, post your code and problem then.

    cLive ;-)

Re: VVP: Cookies - what is in them?
by BUU (Prior) on Apr 24, 2002 at 21:20 UTC
    First off there are two types of cookies. 'Session' and 'non-session'(creative eh?). The session cookies are only stored in ram, and last untill you shut down the browser window, then they die. The non-session cookies last untill a given date, then they die. You can see non-session cookies by going to \windows\cookies (on 98, if you arent on 98 try searching for 'cookies' and see if you can find a folder). And each cookie is stored as a text file here. Note that these text files arent generated untill you shut down the browser, so its hard to keep refreshing something to see the change. But anyways, this is all mostly pointless as theres a simpler way to do this.

    simply type this: javascript:alert(document.cookie); into the address bar at the top of whatever page you want, and it will display all the cookies that page has set on your computer.


    And for the 'non-english cookies', A) they might be url encoded, simply run it through the javascript method for that (go look it up.), or whatever. B) it might be encrypted, in which case, unless you know the key, your screwed.
      The session cookies are only stored in ram, and last untill you shut down the browser window, then they die. The non-session cookies last untill a given date, then they die.

      Just a minor note, on some browsers (notably NetScape, and quite possibly (although untested) Gecko based browsers (Galeon/Mozilla/etc)) "non-session" cookies are stored in memory UNTIL the browser is shut down, at which time they will be written to disk.
      This is only important to think about when you are testing cookie dumping (and/or contents of cookies) and haven't had the precense of mind to close the browser in between sessions.

      Just something to think about,
      JP,
      -- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://161792]
Approved by mce
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found