zoukankan      html  css  js  c++  java
  • asp.net学习笔记·Cookie

    •        Cookie是和站点相关的,每次向服务器请求的时候,除了发送表单参数外,还会将和站点相关的Cookie值都提交给服务器,并且将服务器返回的Cookie更新到浏览器Cookie中去,且这是强制性的;
    •      Cookie的生命周期可以设置;
    •        缺点:Cookie不能存储过多的数据;
    •        网站优化案例:网站图片服务器和主站服务器域名不一样,降低提交Cookie消耗的流量;
    •        变量自增代码示例:
    • using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      
      public partial class 变量自增 : System.Web.UI.Page
      {
          private int a = 0;
          protected void Page_Load(object sender, EventArgs e)
          {
              if (IsPostBack)
              {
                  Response.SetCookie(new HttpCookie("num", "0"));
      //新建HttpCookie对象
                  this.Label1.Text = "0";
              }
          }
          protected void Button1_Click(object sender, EventArgs e)
          {
                int.TryParse(Request.Cookies["num"].Value, out a);
                  a++;
                  Response.SetCookie(new HttpCookie("num", a.ToString()));
                  this.Label1.Text = a.ToString();
             
          }
      }
      

        

  • 相关阅读:
    phonegap helloworld 之android
    perl 信号
    css的浮动
    css的定位
    p4 环境变量的优先级
    oracle sql 高级
    perl数组高级
    让你提升命令行效率的 Bash 快捷键 [完整版]
    函数的返回值为结构体类型
    函数的返回值保存在内存的什么区域
  • 原文地址:https://www.cnblogs.com/xuhongfei/p/2829387.html
Copyright © 2011-2022 走看看