如何保持Cookie值过期 [英] How to maintain cookie value expires

查看:90
本文介绍了如何保持Cookie值过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

在我的Web应用程序中,我将文化价值存储在cookie中,如下所示,

Hi Friends,

In my web app i have store my culture value in cookie as below,

HttpCookie cookie = HttpContext.Current.Request.Cookies["_culture"];
         if (cookie != null)
             cookie.Value = cultureName;
         else
         {
             cookie = new HttpCookie("_culture");
             cookie.HttpOnly = false;
             cookie.Value = cultureName;
             cookie.Expires = DateTime.Now.AddYear(1);
         }
         HttpContext.Current.Response.Cookies.Add(cookie);


但是,一旦我关闭并打开应用程序,cookie就会包含空值.

因此,请提供解决方案以保持cookie值.

在此先感谢

Vimal


But, cookie contain null value once i closed and open my app.

So please give solution to maintain cookie value.

Thanks in Advance

Vimal

推荐答案

检查一下:

cookie-is-lost-when-browser-is-closed [^ ]

希望对您有所帮助:)
check this out:

cookie-is-lost-when-browser-is-closed[^]

hope it helps :)




检查您的浏览器设置,如果您设置了永不记住历史记录",则退出后,Cookie将从您的浏览器中清除.

这可能是问题之一.希望对您有帮助,


谢谢
-amit.
Hi,

check your browser settings, if you have set "Never remember history" then cookies will be clear from your browser after exiting.

this may be one of the problem. hope this will help you,


thanks
-amit.


这篇关于如何保持Cookie值过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆