コード例 #1
0
 public void SessionIDIs32CharsLong()
 {
     for (var i = 0; i < 1000; i++) {
         var session = new UserSession(null, null, DateTime.UtcNow);
         Assert.AreEqual(session.SessionID.Length, 32);
     }
 }
コード例 #2
0
 internal static HttpCookie GetAuthCookie(UserSession session, bool persist)
 {
     if (persist) {
         HttpCookie authCookie;
         var time = TimeSpan.FromDays(3652.5);
         var ticket = new FormsAuthenticationTicket
             (session.SessionID, true, Convert.ToInt32(time.TotalMinutes));
         var encryptedTicket = FormsAuthentication.Encrypt(ticket);
         authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
         authCookie.Expires = DateTime.Now.Add(time);
         return authCookie;
     }
     else {
         return FormsAuthentication.GetAuthCookie(session.SessionID, false);
     }
 }