public void SetUser(APUser user)
 {
     if (user == null)
     {
         this.GetSession()[SessionKeys.ForUser()] = null;
     }
     else
     {
         var serializer = ObjectFactory.Build <IJsonSerializer>();
         var bytes      = serializer.Serialize(user);
         this.GetSession()[SessionKeys.ForUser()] = bytes;
     }
 }
        public APUser GetUser()
        {
            var session   = GetSession();
            var userBytes = session[SessionKeys.ForUser()] as byte[];

            if (userBytes == null || userBytes.Length == 0)
            {
                return(null);
            }
            var serializer = ObjectFactory.Build <IJsonSerializer>();

            return(serializer.Deserialize <APUser>(userBytes));
        }