123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- /*******************************************************************************
- * iNethinkCMS - 网站内容管理系统
- * Copyright (C) 2012-2013 inethink.com
- *
- * @author jackyang <69991000@qq.com>
- * @website http://cms.inethink.com
- * @version 1.3.6.0 (2013-08-14)
- *
- * This is licensed under the GNU LGPL, version 3.0 or later.
- * For details, see: http://www.gnu.org/licenses/gpl-3.0.html
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Web;
- namespace iNethinkCMS.Command
- {
- public class Command_Session
- {
- /// <summary>
- /// 添加Session,有效期为20分钟
- /// </summary>
- /// <param name="strSessionName">Session对象名称</param>
- /// <param name="strValue">Session值</param>
- public static void Add(string strSessionName, string strValue)
- {
- HttpContext.Current.Session[strSessionName] = strValue;
- HttpContext.Current.Session.Timeout = 20;
- }
- /// <summary>
- /// 添加Session,有效期为20分钟
- /// </summary>
- /// <param name="strSessionName">Session对象名称</param>
- /// <param name="strValues">Session值数组</param>
- public static void Adds(string strSessionName, string[] strValues)
- {
- HttpContext.Current.Session[strSessionName] = strValues;
- HttpContext.Current.Session.Timeout = 20;
- }
- /// <summary>
- /// 添加Session
- /// </summary>
- /// <param name="strSessionName">Session对象名称</param>
- /// <param name="strValue">Session值</param>
- /// <param name="iExpires">有效期(分钟)</param>
- public static void Add(string strSessionName, string strValue, int iExpires)
- {
- HttpContext.Current.Session[strSessionName] = strValue;
- HttpContext.Current.Session.Timeout = iExpires;
- }
- /// <summary>
- /// 添加Session
- /// </summary>
- /// <param name="strSessionName">Session对象名称</param>
- /// <param name="strValues">Session值数组</param>
- /// <param name="iExpires">有效期(分钟)</param>
- public static void Adds(string strSessionName, string[] strValues, int iExpires)
- {
- HttpContext.Current.Session[strSessionName] = strValues;
- HttpContext.Current.Session.Timeout = iExpires;
- }
- /// <summary>
- /// 读取某个Session对象值
- /// </summary>
- /// <param name="strSessionName">Session对象名称</param>
- /// <returns>Session对象值</returns>
- public static string Get(string strSessionName)
- {
- if (HttpContext.Current.Session[strSessionName] == null)
- {
- return null;
- }
- else
- {
- return HttpContext.Current.Session[strSessionName].ToString();
- }
- }
- /// <summary>
- /// 读取某个Session对象值数组
- /// </summary>
- /// <param name="strSessionName">Session对象名称</param>
- /// <returns>Session对象值数组</returns>
- public static string[] Gets(string strSessionName)
- {
- if (HttpContext.Current.Session[strSessionName] == null)
- {
- return null;
- }
- else
- {
- return (string[])HttpContext.Current.Session[strSessionName];
- }
- }
- /// <summary>
- /// 删除某个Session对象
- /// </summary>
- /// <param name="strSessionName">Session对象名称</param>
- public static void Del(string strSessionName)
- {
- HttpContext.Current.Session[strSessionName] = null;
- }
- }
- }
|