Tuesday, June 30, 2009

Using ASP.NET Cookies in Javascript and visa-versa

Is any of you creating a module that requires setting cookies and getting it back using javascript? If you want to do so, then you can be in trouble like me! I was trying to set cookies from asp.net code and trying to read the cookie in javascript code, :) bad part of this experience was, I was not able to read the cookies set by asp.net side code.

Then I started googling the proble. I come across several fundamentals, theories and the way asp.net handles the cookies machanism. Finally eggheadcafe has an answer to my problem. Though it was not a straigh forward answer, I got many hints there to solve my problem.

You must be thinking cookie is a vary simple fundamental thing and its nothing to learn about, but believe me, you will find this article informative.

3 comments:

  1. HI prashant,
    i came across same situation. u saved lot of time by redirecting to right post.
    good job.
    chintan GECG

    ReplyDelete
  2. I am still having problems setting cookies in ASP.NET app and reading it in client-side JavaScript. How did you manage to do that? Help please :)

    ReplyDelete
  3. Another option is to use jQuery.cookie plugin.

    ReplyDelete

Please add your valuable comments about this post if it helped you. Thanks