摘要:Silverlight 存取 Cookies
在Silverlight中要設定讀取Cookies並不像以前我們在寫web form這樣下就好
'寫入cookies
Response.Cookies("mycookie").Value = "Love"
'設定cookies期限
Response.Cookies("mycookie").Expires = DateTime.Now().AddHours(1)
'讀取cookies
Response.Write(Request.Cookies("mycookie").Value)
前面有說過Silverlight是Client物件,因此 response 、request 、Session ...等在 System.web
命名名稱下的物件皆無法使用,那麼我們在Silverlight中要如何使用呢 ? 如下
'設定逾時時間
Dim pD_expir As DateTime = DateTime.Now.AddYears(100)
Dim p_Cookie As String = String.Format("{0}={1};expires={2}", "UserSetting", "carousel,daynight,coordinage,flicode,eport,updatetime,", pD_expir.ToString("R"))
'寫入cookies
HtmlPage.Document.SetProperty("cookie", p_Cookie)
'讀取
HtmlPage.Document.Cookies.ToString()
我們來看msdn正規文件怎麼寫
http://msdn.microsoft.com/en-us/library/cc190627(v=vs.95).aspx