session操作类
using System;
using System.Web; /// <summary>
///session操作类
/// </summary>
public class appCookie
{ #region COOKIE 操作相关
/// <summary>
/// 写入Cookie
/// </summary>
/// <param name="strName"></param>
/// <param name="strValue"></param>
public static void WriteCookie(string strName, string strValue)
{
WriteCookie(strName, strValue, );
} public static void WriteCookie(string strName, string strValue, int expires)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];
if (cookie == null)
{
cookie = new HttpCookie(strName);
}
//cookie.Domain = domain;
cookie.Value = strValue;
cookie.Expires = DateTime.Now.AddDays((double)expires);
HttpContext.Current.Response.AppendCookie(cookie);
} public static string GetCookie(string strName)
{
if (((HttpContext.Current.Request.Cookies != null) && (HttpContext.Current.Request.Cookies[strName] != null)))
{
return HttpContext.Current.Request.Cookies[strName].Value;
}
return "";
} #endregion }
session操作类的更多相关文章
- C#语法糖之 session操作类 asp.net
用法: //声名一个数据集合 var listString = new List<string>() { "a", "b", "c&quo ...
- C# Session 操作类
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Session帮助类
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...
- C#操作session的类实例
本文实例讲述了C#操作session的类.分享给大家供大家参考.具体分析如下: 这个C#类对session操作进行了再次封装,可以大大简化session的常用操作,同时这个类可以将session值设置 ...
- C#语法糖之 cache操作类 asp.net
因为考虑到我下面我将写session cookies 等 操作类 ,与cache具有共性. 所以都统一继承了IHttpStorageObject abstract class 来保函数风格的统一 , ...
- php redis数据库操作类
<?php namespace iphp\db; use iphp\App; /** * redis操作类 * 说明,任何为false的串,存在redis中都是空串. * 只有在key不存在时, ...
- php-redis 操作类 封装
<?php /** * redis操作类 * 说明,任何为false的串,存在redis中都是空串. * 只有在key不存在时,才会返回false. * 这点可用于防止缓存穿透 * */ cla ...
- C# 文件操作类大全
C# 文件操作类大全 时间:2015-01-31 16:04:20 阅读:1724 评论:0 收藏:0 [点我收藏+] 标签: 1.创建文件夹 //usin ...
- 封装php redis缓存操作类
封装php redis缓存操作类,集成了连接redis并判断连接是否成功,redis数据库选择,检测redis键是否存在,获取值,写入值,设置生存时间和删除清空操作. php redis类代码: &l ...
随机推荐
- java之Pattern类详解
在JDK 1.4中,Java增加了对正则表达式的支持. java与正则相关的工具主要在java.util.regex包中:此包中主要有两个类:Pattern.Matcher. Pattern 声明: ...
- 解决Hive与Elasticsearch共有库 guava 冲突 NoSuchMethodError
情况描述 解决方法 方法一:Shade and relocate 简介 Shade Elasticsearch 引入shade ES jar 方法二:修改集群Job配置策略(未实验) 情况描述 使用J ...
- 基于Java实现批量下载网络图片
昨天朋友做项目遇到一个需求,需要把上千个的微博表情图片下载到本地磁盘,并做好规范命名,塞给我一堆Json数据,让我帮忙处理下,反正闲着也没事干,就帮忙写了.(很简单的一个功能,随手记录下,刚好填补下最 ...
- [Node.js] 01 - How to learn node.js
基本概念 链接:https://www.zhihu.com/question/47244505/answer/105026648 链接:How to decide when to use Node.j ...
- ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
在开发一个python项目是,需要用到mysql,但是, 安装完mysql-python后import加载模块提示以下错误: ImportError: libmysqlclient_r.so.16: ...
- android基础---->XMl数据的解析
在网络上传输数据时最常用的格式有两种,XML和JSON,下面首先学一下如何解析XML格式的数据,JSON的解析可以参见我的博客(android基础---->JSON数据的解析).解析XML 格式 ...
- LeetCode - 872. Leaf-Similar Trees
Consider all the leaves of a binary tree. From left to right order, the values of those leaves form ...
- Bitcoin源代码编译安装详解
一.安装准备 安装环境:虚拟机Ubuntu 16.04 内存:2G 错误1:如果这里内存分配为1G,则会产生如下错误: g++ : internal compiler error: Killed (p ...
- linux-Centos 7下tftp-server服务的安装与配置
TFTP(Trivial File Transfer Protocol,简单文件传输协议)是TCP/IP协议族中的一个用来在客户机与服务器之间 进行简单文件传输的协议,提供不复杂.开销不大的文件传输服 ...
- How to view assertions in the Verdi waveform viewer
In the Cadence Simvision waveform viewer, I can see every assertions listed as a hierarchical signal ...