IT認證考古題|IT認證題庫|IT認證考試信息 --Killtest考古題網

關於ASP.NET/C#中對Cookie的讀寫操作

關於ASP.NET/C#中對Cookie的讀寫操作

2010年10月20日 by admin

寫cookie

  HttpCookie cookie = new HttpCookie(“Info”);//定義cookie對象以及名為Info的項

  DateTime dt = DateTime.Now;//定義時間對象

  TimeSpan ts=new TimeSpan(1,0,0,0);//cookie有效作用時間,具體查msdn

  cookie.Expires = dt.Add(ts);//添加作用時間

  cookie.Values.Add(“user”,”cxbkkk”);//增加屬性

  cookie.Values.Add(“userid”,”1203″);

  Response.AppendCookie(cookie);//確定寫入cookie中

  讀取cookie

  if(Request.Cookies[“Info”]!=null)

  {

  string temp=Convert.ToString(Request.Cookies[“Info”].Values[“user”])+” “+Convert.ToString(Request.Cookies[“Info”].Values[“userid”]);

  //讀全部就用Request.Cookies[“Info”].Value)

  if(temp==””)

  {

  Response.Write(“空”);

  }

  else

  Response.Write(temp);

  }

  else

  {

  Response.Write(“error”);

  }

Posted in: KillTest Tagged: ASP.NET, C++, Cookie

分類

標籤

1z0-042 1Z0-851 1Z0-873 70-640 70-642 70-680 220-701 220-702 310-065 640-802 642-813 642-832 642-902 A+ Apple CCDA CCDP CCIE CCNA CCNP CCSP Cisco CIW COMPTIA DBA EMC EMC Certification HCSE HP IBM IBM Certification JAVA Java Standard Edition 6 Programmer Certified Professional Exam JN0-660 Linux LPI MCITP MCSE MCTS Microsoft Network+ Oracle SCJP Security+ SUN

Copyright © 2025 IT認證考古題|IT認證題庫|IT認證考試信息 --Killtest考古題網.

Custom WordPress Theme by themehall.com

  • Viasat Customer Agreement
  • Piercing Agreement Form
  • Isda Cds Agreement
  • Uk Egypt Association Agreement
  • Us New Zealand Trade Agreement
  • Simple Loan Contract between Family
  • What Is the Effect of Termination of a Contract
  • Lupc Framework Agreement
  • The Contractor Fight Reviews
  • Property Management Agreement in Kenya
  • Legal Definition Cancel a Contract
  • South Dakota Vehicle Purchase Agreement
  • Shared Equity Financing Agreement Pennsylvania
  • Sale Agreement Duration
  • Rental Agreement Registration Format
  • Quickpay Agreement Id
  • Investment Agreement Nigeria
  • Party Wall Agreement Details
  • 50 Shades of Grey Agreement Pdf
  • When Does a Cause of Action Accrue for Breach of Contract