Re: [Cppcms-users] async session
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2013-06-22 17:01:05
|
Because by default the session does not exists and it is "ok". The only use case of load() is loading sessions in async applications that session load can be costly (sql query for example) and you don't want to load it by default. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: Marcel Hellwig <ke...@co...> >To: cpp...@li... >Sent: Saturday, June 15, 2013 10:46 PM >Subject: Re: [Cppcms-users] async session > > >On 14.06.2013 17:50, Marcel Hellwig wrote: >> Hi *, >> >> I use basic HTML pages for displaying and json_rpc_server as backend for >> logic etc. >> >> What is a good/the best way to do this? >> I was trying to do that with the session interface. But how safe is >> that? How is a user indentified? Could I just return the session ID? If >> yes, how? I tried this: >After some time thinking about this my conclusion is that is not good to >return the session_cookie itself, instead I let handle cppcms the >session managment. But there is a little error in the code below, which >I was not aware of. >>> void WebAPI::login(username, password) { >>> //validation >before setting any thing to the session you have to load it via >>> session().load(); //important!!! >>> session().set("username", username); >>> session().save(); >>> >>> return_result(session().get_session_cookie()); >>> } >> But it does not work :/ >Now it works. >> I hope someone has approached this situation. >> >> Regards >> Marcel >The only weird thing is that the following worked, but it shouldn't >> if(!session().load() || !session().is_set("username")) >> { >> return_error("Invalid Session"); >> return; >> } >remember that I forgot to load the session in "login"? So at least >session().is_set should say no and give the error. Why does it no do so? > >Regards > > > >------------------------------------------------------------------------------ >This SF.net email is sponsored by Windows: > >Build for Windows Store. > >http://p.sf.net/sfu/windows-dev2dev >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |