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 ...
随机推荐
- 卷积、矩阵乘积、高斯模糊滤波(降噪)、空域计算(2D卷积计算)、频域计算(FFT)的理解
矩阵乘积:对应行列对应元素相乘的和组成新的矩阵 两个矩阵的乘法仅当第一个矩阵A的列数和另一个矩阵B的行数相等时才能定义.如A是m×n矩阵和B是n×p矩阵,它们的乘积C是一个m×p矩阵 并将此乘积记为: ...
- linux mysql卸载
卸载mysql 1.查找以前是否装有mysql 命令:rpm -qa|grep -i mysql 可以看到mysql的包: mysql-libs-5.1.71-1.el6.x86_64 2.删除mys ...
- Git服务器环境搭建(打造属于自己的存储库)
Git服务器搭建之CentOs7-阿里云搭建 首先使用连接工具连接到远程的阿里云服务器CentOs7上. 1.安装Git及创建用户 # 安装Git $ yum install git # 创建一个gi ...
- 【NLP】分词 新词
基于大规模语料的新词发现算法 https://blog.csdn.net/xgjianstart/article/details/52193258 互联网时代的社会语言学:基于SNS的文本数据挖掘 h ...
- 在springBoot中配置web.xml中配置的servlet
第一种 web.xml (截取的需要转换的) 当拦截到 /socke t时执行该servlet <servlet> <servlet-name>websocket</se ...
- redis如何后台启动
当安装好redis之后,运行redis-server命令之后,显示如图所示: 但是这样没有办法在这个tab下做任何操作了,因为这个时候使用Ctrl+c之后,就变成了这个样子 然后就关闭了,那么我想让r ...
- 使用LevelListDrawable实现Html.fromHtml多张图片显示
stackoverflow网站果然强大,帮了我不少忙! http://stackoverflow.com/questions/16179285/html-imagegetter-textview 首先 ...
- mongodb new file allocation failure
话说那天正在向mongodb中写入数据,突然就蹦出了 new file allocation failure ,以为是数据有错误,就检查了一番,可没问题啊,看着像是mongo自己的问题,于是百度了一番 ...
- mui---计算缓存大小及清除缓存
在做APP项目的时候,考虑到APP的的缓存文件太大,会考虑在APP内部设置清除缓存的功能. 具体方法: http://www.dcloud.io/docs/api/zh_cn/cache.html h ...
- oracle相关的知识
01.表空间的创建与删除 Spool 目录 (把sql语句都记录在txt文件中)spool e:\xxx.txtSpool off 结束 SQL> --清除屏幕信息SQL> cle ...