示例#1
0
        public static Entities.LoggedInAccount SetStudent(HttpContext context, Entities.Student student, bool fullProcess = false)
        {
            var account = new Entities.LoggedInAccount {
                Id          = student.Id,
                UserName    = student.Email,
                accountType = Entities.eAccountType.Student
            };

            context.Response.Cookies.Add(new HttpCookie(KEY_STUDENT, account.CookieValue)
            {
                Expires = DateTime.Now.AddDays(7),
                Secure  = true,
            });

            context.Session[KEY_STUDENT] = account;

            if (fullProcess)
            {
                // no multiple connections allowed
                // clear all connected sessions and add only the current one
                ConnectedSessionsSingleTon.Instance.MarkAllToRemove(student.Id);
                ConnectedSessionsSingleTon.Instance.Add(new ConnectedSession
                {
                    StudentId = student.Id,
                    Session   = context.Session
                });
            }

            return(account);
        }
示例#2
0
 public static void SetAccount(HttpContext Context, Entities.LoggedInAccount Account)
 {
     Context.Response.Cookies.Add(new HttpCookie(KEY_ACCOUNT, JsonConvert.SerializeObject(Account))
     {
         Expires = DateTime.Now.AddDays(60),
         Secure  = true,
     });
 }
示例#3
0
 public static void SetAccount(HttpContext Context, Entities.LoggedInAccount Account)
 {
     Context.Session[KEY_ACCOUNT] = Account;
 }