cookie values disappear when traversing between content pages

后端 未结 4 1820
傲寒
傲寒 2020-12-10 20:46

in my app. there\'s a log in mechanism which save a cookie with the info of the user who just logged in

     private void CreateCookie(LoginEventArgs args)
         


        
4条回答
  •  情歌与酒
    2020-12-10 21:11

    o'k , the problem was unthinkable
    special thanks to Peter Bromberg

    http://www.eggheadcafe.com/tutorials/aspnet/198ce250-59da-4388-89e5-fce33d725aa7/aspnet-cookies-faq.aspx

    in the section of the Article " The Disappearing Cookie "

    the author states that if you have a watch on Response.Cookies["cookie_name"] the browser creates a new empty cookie that overrides your cookie .

    i used such a watch which made my cookie loose it's values ,and when i took it off the cookie kept its values.

    the moral is DON't WATCH Response.Cookies[" "] also i read in some other post that if you check

     if( Response.Cookies["cookie_name"] != null    )  
    

    for example it also gets overridden.

提交回复
热议问题