Re: [Cppcms-users] async session
Brought to you by:
artyom-beilis
|
From: Marcel H. <ke...@co...> - 2013-06-15 19:47:15
|
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
|