{"action":"created","issue":{"url":"https://api.github.com/repos/ServiceStack/Issues/issues/261","labels_url":"https://api.github.com/repos/ServiceStack/Issues/issues/261/labels{/name}","comments_url":"https://api.github.com/repos/ServiceStack/Issues/issues/261/comments","events_url":"https://api.github.com/repos/ServiceStack/Issues/issues/261/events","html_url":"https://github.com/ServiceStack/Issues/issues/261","id":63044691,"number":261,"title":"can't read the session-Id from  the user session","user":{"login":"stefan2410","id":1259393,"avatar_url":"https://avatars.githubusercontent.com/u/1259393?v=3","gravatar_id":"","url":"https://api.github.com/users/stefan2410","html_url":"https://github.com/stefan2410","followers_url":"https://api.github.com/users/stefan2410/followers","following_url":"https://api.github.com/users/stefan2410/following{/other_user}","gists_url":"https://api.github.com/users/stefan2410/gists{/gist_id}","starred_url":"https://api.github.com/users/stefan2410/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefan2410/subscriptions","organizations_url":"https://api.github.com/users/stefan2410/orgs","repos_url":"https://api.github.com/users/stefan2410/repos","events_url":"https://api.github.com/users/stefan2410/events{/privacy}","received_events_url":"https://api.github.com/users/stefan2410/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-19T17:21:46Z","updated_at":"2015-03-19T19:29:43Z","closed_at":null,"body":"We had tested  the code with version  4.0.36  and it worked . With the new version we have problem, The session-Id  returns empty. I  call  our  special service to  post  to the authenticate. and returns the custom session .  Session returns authenticated with data from the userAuth table and our  specific info but without SessionId.  Also the cookie in the client is without Id.\r\nI hope we did not do any stupid error and we destroy our previous  correct code.\r\nΙ had tried yesterday to save the session in Sql Server - CacheEntry, but the session saved with Id= urn:session without the Id.\r\nin AppHost. Configure    (selfhost)\r\n\r\n             container.Register<ICacheClient>(new MemoryCacheClient());\r\n             container.Register<ISessionFactory>(c => new SessionFactory(c.Resolve<ICacheClient>()));\r\n            Plugins.Add(new AuthFeature(\r\n               () => new APIAuthUserSession(),\r\n              new[] { new APICredentialsAuthProvider() }    \r\n            ));  \r\n            //Requires ConnectionString configured in Web.Config\r\n             container.Register<IDbConnectionFactory>(c =>\r\n                new OrmLiteConnectionFactory(ServiceSettings.DataConnection, SqlServerDialect.Provider));\r\n            container.Register<IUserAuthRepository>(c =>\r\n                new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));\r\n            var authRepo = (OrmLiteAuthRepository)container.Resolve<IUserAuthRepository>();\r\n            if (ServiceSettings.RecreateAuthTables)\r\n                authRepo.DropAndReCreateTables(); //Drop and re-create all Auth and registration tables\r\n            else                  authRepo.InitSchema();  \r\n//-----\r\n\r\n\r\n         public class APIAuthUserSession : AuthUserSession\r\n        {\r\n              public string GrmUserRole { get; set; }   \r\n           // ......\r\n          public string AppId { get; set; }\r\n        public override void OnAuthenticated(IServiceBase authService, IAuthSession session,   IAuthTokens    tokens, System.Collections.Generic.Dictionary<string, string> authInfo)\r\n        {\r\n           base.OnAuthenticated(authService, session, tokens, authInfo);\r\n            if (session.UserName == \"myadmin\")\r\n            {\r\n                APIAuthUserSession apisession = session as APIAuthUserSession;\r\n                if (apisession != null)                           \r\n                    apisession.GrmUserRole = \"OPERATOR\";                 \r\n              //....\r\n              }    \r\n           }   \r\n      }\r\n\r\n         public class APICredentialsAuthProvider : CredentialsAuthProvider\r\n        {\r\n        public APICredentialsAuthProvider()\r\n            : base()\r\n        {                 this.Provider = \"APIAuthCredentials\";        }    \r\n    }\r\n//-----\r\n\r\n\r\n\r\n       public APIAuthenticateResponse Post(APIAuthenticate request)\r\n        {\r\n            using (var auth = base.ResolveService<AuthenticateService>())\r\n            {\r\n                var provider_request = new Authenticate\r\n                {\r\n                    provider = \"APIAuthCredentials\",\r\n                    UserName = request.UserName,\r\n                    Password = request.Password,\r\n                    RememberMe = request.RememberMe,\r\n\r\n                };\r\n                AuthenticateResponse authResponse = null;\r\n                try\r\n                {\r\n                    var response = auth.Post(provider_request);\r\n                    authResponse = response as AuthenticateResponse;\r\n                    \r\n                }\r\n                catch (HttpError err)\r\n                {\r\n                    return new APIAuthenticateResponse() { Success = false, Message = err.Message, ErrorCode = err.StatusCode.ToString() };                  \r\n                }\r\n                catch (Exception err)\r\n                {\r\n                    return new APIAuthenticateResponse() { Success = false, Message = err.Message };                 \r\n                }\r\n                finally { }\r\n                \r\n                if (authResponse == null)                 \r\n                    return new APIAuthenticateResponse() {  Success = false, Message = \"error\"  };\r\n               \r\n                 var session = base.SessionAs<APIAuthUserSession>();\r\n\r\n                 if (!session.IsAuthenticated)\r\n                      return new APIAuthenticateResponse() {  Success = false, Message = \"User not                Authenticated\"  };\r\n              \r\n                    session.AppId = request.AppId;\r\n              \r\n                    if ((bool)request.RememberMe)\r\n                        this.SaveSession(session, new TimeSpan(7, 0, 0, 0));\r\n                    else\r\n                        this.SaveSession(session, new TimeSpan(0, 3, 0, 0));\r\n\r\n                   return   new APIAuthenticateResponse()\r\n                    { \r\n                        SessionId = authResponse.SessionId,\r\n                        ReferrerUrl = authResponse.ReferrerUrl,                        \r\n                        GrmUserRole = session.GrmUserRole,\r\n                     // ...........................................\r\n                     \r\n                        Success = true\r\n                    };\r\n                 }\r\n\r\n     public class APIAuthenticateResponse\r\n         {\r\n        public bool Success { get; set; }\r\n        public string Message { get; set; }\r\n          public string        GrmUserRole { get; set; }\r\n      //   .......\r\n       }\r\n"},"comment":{"url":"https://api.github.com/repos/ServiceStack/Issues/issues/comments/83731344","html_url":"https://github.com/ServiceStack/Issues/issues/261#issuecomment-83731344","issue_url":"https://api.github.com/repos/ServiceStack/Issues/issues/261","id":83731344,"user":{"login":"stefan2410","id":1259393,"avatar_url":"https://avatars.githubusercontent.com/u/1259393?v=3","gravatar_id":"","url":"https://api.github.com/users/stefan2410","html_url":"https://github.com/stefan2410","followers_url":"https://api.github.com/users/stefan2410/followers","following_url":"https://api.github.com/users/stefan2410/following{/other_user}","gists_url":"https://api.github.com/users/stefan2410/gists{/gist_id}","starred_url":"https://api.github.com/users/stefan2410/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefan2410/subscriptions","organizations_url":"https://api.github.com/users/stefan2410/orgs","repos_url":"https://api.github.com/users/stefan2410/repos","events_url":"https://api.github.com/users/stefan2410/events{/privacy}","received_events_url":"https://api.github.com/users/stefan2410/received_events","type":"User","site_admin":false},"created_at":"2015-03-19T19:29:43Z","updated_at":"2015-03-19T19:29:43Z","body":"both they have not value,  session and authResponse \r\nbut the authResponse does not return null and session has all fields   with  values ( these from the UserAuth table  and our custom. It comes also Autheticated.  Now I try, reading other issues here,  to add the SessionId manually, before I save the Session. to see what happens. I will try  to send you code."}}