Esempio n. 1
0
        /// <summary>
        /// Gets the session identity.
        /// </summary>
        /// <returns>The session identity.</returns>
        /// <param name="ctx">Context.</param>
        public static CustomSessionIdentity GetSessionIdentity(System.Net.HttpListenerContext ctx)
        {
            CustomSessionIdentity ret;

            System.Net.CookieCollection coll = ctx.Request.Cookies;

            if (coll[RESTKeys.SessionCookieId] == null ||
                string.IsNullOrEmpty(coll[RESTKeys.SessionCookieId].Value))
            {
                //needs a new identity
                ret = CustomSessionIdentity.CreateNew();
            }
            else if (coll[RESTKeys.SessionCookieId].Expired)
            {
                //needs a new identity
                ret = CustomSessionIdentity.CreateNew();
            }
            else
            {
                //needs an existing identity
                ret = CustomSessionIdentity.Retrieve(coll[RESTKeys.SessionCookieId].Value,
                                                     coll[RESTKeys.SessionCookieToken].Value);
            }
            foreach (System.Net.Cookie c in ret.GetCookies())
            {
                ctx.Response.Cookies.Add(c);
            }
            ret.ctx = ctx;
            return(ret);
        }
Esempio n. 2
0
 /// <summary>
 /// Creates this instance
 /// </summary>
 public override de.netcrave.nMVC.Models.DomainObjectBase Create()
 {
     return(CustomSessionIdentity.CreateNew());
 }