如何将Cookie过期设置为“会话",在C#中? [英] How do I set cookie expiration to "session" in C#?

查看:63
本文介绍了如何将Cookie过期设置为“会话",在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自我解释.在PHP中,解决方案是将cookie过期时间设置为0;否则,将cookie过期时间设置为0.我不确定C#,因为它需要一个DateTime值.

Self-Explanatory. In PHP, the solution would be to set the cookie expiration to 0; I'm unsure about C# since it requires a DateTime value.

推荐答案

将Expires属性设置为MinValue将此会话设置为Cookie,这是它的默认值.

Setting the Expires property to MinValue makes this a session Cookie, which is its default value.

cookie.Expires = DateTime.MinValue

这篇关于如何将Cookie过期设置为“会话",在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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