zoukankan      html  css  js  c++  java
  • SessionHelper

    MXS&Vincene  ─╄OvЁ  &0000009 ─╄OvЁ  MXS&Vincene 

    MXS&Vincene  ─╄OvЁ:今天很残酷,明天更残酷,后天很美好,但是绝大部分人是死在明天晚上,只有那些真正的英雄才能见到后天的太阳。

    MXS&Vincene  ─╄OvЁ:We're here to put a dent in the universe. Otherwise why else even be here? 

     

    正文>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    public  class SessionHelper
    {
    /// <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;
    }
    }

  • 相关阅读:
    oracle依据注释查询表信息
    oracle中建表后添加注释
    第四章:联机分析处理olap
    第三节:数据仓库与ODS
    第二节:数据仓库系统的体系结构
    第一节:数据库与数据仓库
    视图
    oracle中生成随机数的方法
    oracle两表中的两列进行模糊匹配的方法
    Oracle基本操作
  • 原文地址:https://www.cnblogs.com/moxuanshang/p/4645859.html
Copyright © 2011-2022 走看看