Ejemplo n.º 1
0
 /// <summary>
 /// 删除 Session
 /// </summary>
 public void RemoveSession()
 {
     AutoCSer.Net.HttpDomainServer.ISession session = Session;
     if (session != null)
     {
         setSessionId();
         if (sessionId.Ticks != 0)
         {
             session.Remove(ref sessionId);
             getSessionCookie().Set(NullValue <byte> .Array, Pub.MinTime, Socket.HttpHeader.Host, AutoCSer.Net.Http.Cookie.DefaultPath, false, true);
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 设置 Session 值
 /// </summary>
 /// <param name="value">值</param>
 /// <returns>是否设置成功</returns>
 public bool SetSession(object value)
 {
     AutoCSer.Net.HttpDomainServer.ISession session = Session;
     if (session != null)
     {
         setSessionId();
         if (session.Set(ref sessionId, value))
         {
             setSessionCookie();
         }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 设置Session值
        /// </summary>
        /// <param name="value">值</param>
        /// <typeparam name="valueType">值类型</typeparam>
        /// <returns>是否设置成功</returns>
        public bool SetSession <valueType>(valueType value)
        {
#if NOJIT
            AutoCSer.Net.HttpDomainServer.ISession session = Session;
#else
            AutoCSer.Net.HttpDomainServer.ISession <valueType> session = Session as AutoCSer.Net.HttpDomainServer.ISession <valueType>;
#endif
            if (session != null)
            {
                setSessionId();
                if (session.Set(ref sessionId, value))
                {
                    setSessionCookie();
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public valueType GetSession <valueType>(valueType nullValue) where valueType : struct
        {
#if NOJIT
            AutoCSer.Net.HttpDomainServer.ISession session = Session;
#else
            AutoCSer.Net.HttpDomainServer.ISession <valueType> session = Session as AutoCSer.Net.HttpDomainServer.ISession <valueType>;
#endif
            if (session != null)
            {
                setSessionId();
#if NOJIT
                if (sessionId.Ticks != 0)
                {
                    return((valueType)session.Get(ref sessionId, nullValue));
                }
#else
                if (sessionId.Ticks != 0)
                {
                    return(session.Get(ref sessionId, nullValue));
                }
#endif
            }
            return(nullValue);
        }