简体   繁体   English

从Silverlight应用程序将cookie设置为HttpOnly

[英]Set cookie as HttpOnly from Silverlight application

I'm trying to set a cookie as HttpOnly from within my Silverlight application using the following code: 我正在尝试使用以下代码在Silverlight应用程序中将cookie设置为HttpOnly:

string cookie = String.Format("{0}={1};expires={2};HttpOnly", key, value, expiration.ToString("R"));
HtmlPage.Document.SetProperty("cookie", cookie);

When I add the "HttpOnly" to the end of the cookie string, the cookie never actually gets set. 当我将“HttpOnly”添加到cookie字符串的末尾时,cookie实际上从未被设置。 I'm suspecting that the Silverlight application is considered a script, which would mean that it doesn't have access to HttpOnly cookies. 我怀疑Silverlight应用程序被认为是一个脚本,这意味着它无法访问HttpOnly cookie。

Is there any other way to get/set cookies in Silverlight such that I would be able to set the HttpOnly attribute? 有没有其他方法可以在Silverlight中获取/设置cookie,以便我能够设置HttpOnly属性?

The cookie never actually get sets because there is no property named HttpOnly exists cookie实际上从未获得集合,因为没有名为HttpOnly的属性存在

Below have listed what property cookie consists of : 下面列出了属性cookie包含的内容:

Property values

1) name=value
2) expires=date
3) domain=domainname
4) path=path
5) secure -> If you set a cookie as secure, the stored cookie information can be accessed only from HTTPS.

For detailed explaination on specific properties below is the link : 有关以下特定属性的详细说明,请链接:

https://msdn.microsoft.com/en-us/library/ms533693(VS.85).aspx https://msdn.microsoft.com/en-us/library/ms533693(VS.85).aspx

There is no other way to set the cookie in silverlight , only approach is what you are doing is the one 没有其他方法可以在Silverlight中设置cookie,唯一的方法是你正在做的就是那个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM