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");
    }
    }
    }
    }
    }

  • 相关阅读:
    python
    springboot-mybatis-pagehelper(分页插件)
    图片验证码工具类
    http工具类
    page工具类
    生成count位随机数工具类
    日期工具类
    dozer工具类
    list自定义排序工具类
    fastJson工具类
  • 原文地址:https://www.cnblogs.com/kexb/p/3660397.html
Copyright © 2011-2022 走看看