zoukankan      html  css  js  c++  java
  • 创建cookie

    cookie的创建
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace AspDotNet04
    {
    public partial class C10CookieLogin : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (Request.HttpMethod.ToLower() == "post")
    {
    string strN = Request.Form["txtN"];
    string strP = Request.Form["txtP"];
    //登录成功
    if (strN == "admin" && strP == "123")
    {
    //创建Cookie,存入 键值对
    HttpCookie cookie = new HttpCookie("cname",strN);
    //设置失效时间(硬盘Cookie) - 2分钟
    cookie.Expires = DateTime.Now.AddMinutes(2);
    //设置cookie的Path
    //cookie.Path = "/admin/";
    //cookie.Domain = "www.baidu.com";
    //加入响应报文对象
    Response.Cookies.Add(cookie);

    //让浏览器 重定向 到首页
    Response.Redirect("C11CookieIndex.aspx");
    //Response.Redirect("/admin/CookieIndex.aspx");
    }
    }
    }
    }
    }

  • 相关阅读:
    企业级应用和互联网应用的区别
    JAVAEE课程目标
    组队项目--投票管理系统
    关于JSON
    Ajax技术学习
    Applet的学习
    Async的相关学习
    Filter分析
    JavaEE-map
    Session
  • 原文地址:https://www.cnblogs.com/kexb/p/3660397.html
Copyright © 2011-2022 走看看