Page options

Cookie使用


1. 存储cookie

    HttpCookie cookie;
    cookie=new HttpCookie("frenquency");
   // cookie.Domain = AppConfig.DomainName;
    cookie.Values.Add("hrid",Session["hRID"].ToString());
    int days = Convert.ToInt32(this.ddlFrequency.SelectedValue);
    cookie.Expires=DateTime.Now.AddDays(days);
   Response.AppendCookie(cookie);

2. 读取cookie

HttpCookie cookie = Request.Cookies["frenquency"];

存在一下问题:

1. Cookie值的获取,使用cookie.values["hrid"]无法获取。查看后,在保存时已经将value保存到cookie中,但在读取时,发现cookie为空。

2. 在aspx文件使用cookie

 

    Post a comment

    Your Name or E-mail ID (mandatory)

     

    Note: Your comment will be published after approval of the owner.

    No Attachments Found. Click here to upload new file.




     RSS of this page

    Author: ronliu   Version: 1.0   Last Edited By: ronliu   Modified: 11 Jun 2008