HttpCookie uid = new HttpCookie( "username", 用户.用户名);
Response.Cookies.Add( uid );
HttpCookie upwd = new HttpCookie( "userPWD", 用户.密码 );
Response.Cookies.Add( upwd );

解决方案 »

  1.   

    sqhua(拉长弓,射天狼):
      你写的,我不明白,
    在Temporary Internet Files看到是这样的
    我就是不明白怎么文件的名称是Cookies:[email protected] 
    到底是怎么写出来的。。 名称 Cookies:[email protected]   internet地址 Cookies:[email protected]
      

  2.   

    "liuk" is your login name to your machine, right? 
    "ok100.alleys.com" is a site you visited, right?
    that is how the browser named the cookie filesif CSDN puts a cookie on your machine, the cookie file will be probably named as [email protected]
      

  3.   

    请加上一句表示cookie有效:
    cookie.expires=10
      

  4.   

    To:saucer(思归) 
      That is Right.But How to Use C# to Do It,I Understand the cookie which write to the local machin.
      In my mind , what can i do like that write the cookie to the local machine like Cookies:[email protected]  .
      Who Can  Give Me the Code??  Waiting Online!!! 
      

  5.   

    >>>"write the cookie to the local machine"? you mean you want to simulate the browser and write a cookie file? just use System.IO.File's CreateText method to create a text file and write to it, :-)
      

  6.   

    To :saucer(思归) 
      No, U miss my means.
      I want to use C# Write Cookies, but I do't understand How to write the cookies code.
     like under code  , it can write the cookie to the client side
     Code Example:
     HttpCookie cookie = new HttpCookie("strCookieName");
      //Set the cookies value
      cookie.Value = "ValueField.Text";
      Response.Cookies.Add(cookie);   
      cookie.Domain="www.alleys.com";
      cookie.Path = "/tt";
     But The Result is Cookies file Name is "/tt"
     I Want The Result is 
       名称 Cookies:[email protected]   
     What Can I Do !!  waiting online!
      

  7.   

    you have to be on www.alleys.com to do that, or at least fool the browser to believe you are on www.alleys.com
      

  8.   

    i know.but i sent the code to www.****.com .
      in my browser, i  run the code but it is no what u say 
      the cookies file in my machine 'name is "/tt"
      that make me two week to do it, but it no way to make it true.
    give me mind??
      

  9.   

    cookie.Values.Add("loginid", txtloginid.Text)
                    cookie.values.Add("branch", dropBranch.SelectedItem.Value)                cookie.Expires = DateTime.MaxValue
                    Response.AppendCookie(cookie)
      

  10.   

    To: liqilinlove(MasterCSharp) 
      your method is only to add cookies, but my question is how to make a cookie file name to be which u like control it... 
      

  11.   

    cookie.expires=now.adddays(10)如果不规定cookie保存的时间,那么浏览器一但结束会话就删除cookie。
      

  12.   

    写Cookie的代码,包括读取和写入的代码:
    http://expert.csdn.net/Expert/topic/1082/1082426.xml?temp=.6507837
      

  13.   

    How to Write and read Cookies, i know,but i do't know how to do that like example