コード例 #1
0
        public static SessaoSistema GetSession(HttpContext context)
        {
            SessaoSistema sessao = null;

            try
            {
                var cookieSessao = Base64Decode(Uri.UnescapeDataString(context.Request.Cookies[MD5("SessaoAppSaude")]));
                sessao = Newtonsoft.Json.JsonConvert.DeserializeObject <SessaoSistema>(cookieSessao);

                return(sessao);
            }
            catch
            {
                return(sessao);
            }
        }
コード例 #2
0
 public static void NewSession(HttpContext context, SessaoSistema sessao)
 {
     try
     {
         var sessaoBase64 = Uri.EscapeDataString(Base64Encode(Newtonsoft.Json.JsonConvert.SerializeObject(sessao, Newtonsoft.Json.Formatting.None)));
         context.Response.Cookies.Append(MD5("SessaoAppSaude"),
                                         sessaoBase64
                                         , new CookieOptions()
         {
             Expires = DateTime.Now.AddDays(30)
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }