TEMPESTINI.NET

Observations in Software Development

Archive for August, 2007

Permanent vs. Temporary Cookies

Posted by Rick Tempestini on August 18, 2007

Cookies, by default, when created using the following code sample, expire when the browser closes:

code-sample-cookie-no-expiration.jpg

If, however, the Expires property is set to a date and time in the future of the current date and time, a persistent cookie file will be written to the local client hard drive. For Internet Explorer, cookies are placed in the c:\Documents and Settings\[user_name]\Cookies directory.

Therefore, the code sample below will write a permanent cookie to the clients hard drive because the Expire property was set to a time in the future.

code-sample-cookie-with-expiration.jpg

Now, looking into my local cookies directory I see my new cookie file:

file-explorer-with-new-cookie.jpg

If I open the cookie, I can now see the name of the cookie “TestCookie” and the name-value pair that I stored in the cookie: setting1-test.

test-cookie.jpg

Posted in Other | Tagged: , , | 4 Comments »

 
Follow

Get every new post delivered to your Inbox.