Re: [Cppcms-users] SSE keep-alive
Brought to you by:
artyom-beilis
|
From: Christian G. <chr...@gm...> - 2013-04-02 20:46:06
|
2013/4/2 Artyom Beilis <art...@ya...>:
> Small notes:
>
> 1. Session is saved when the output stream is accessed first time, as you
> need to provide set session cookies.
>
> Remember the session data may be stored entirely on the client
> side in signed cookies.
>
"session" : {
"expire" : "renew",
"timeout" : 15,
"location" : "server",
"gc" : 10,
"server": {
"storage":"memory"
}
},
The session data itself is store on the server side - or?
> Saving session after output was provided is similar to an attempt
> to set a cookie **after** HTTP headers were sent.
>
Okay
> 2. Calling changing session values and calling save after the output
> was generated has undefined behavior.
>
I am not changing any value stored in the session. I only want to renew
the session. For me it is a problem when the cppcms session gets deleted
if a script runs e.g. 15 minutes. On the client side there is only one open
SSE stream.
> So your code is incorrect.
>
> I think you mix up two different things: HTTP Stream session - the
> state where the connection is open and you push the data to the stream
> (it is represented by cppcms::http::context and actual open TCP/IP socket)
> and the CppCMS/Web session the information shared **accorss** different
> connections - that is based cookies - the state for stateless HTTP.
>
As far as I can tell from studying the source code a cppcms::http::context gets
created if the client does a get/post.
This context has access to the request(), the response() and the assigned cppcms
session().
In my case the life-time strategy is set to "renew". This means the
client needs to
do a get/post to create a cppcms::http::context as this action will
trigger the "renew"
logic - or?
Is there a way to do the "renew" of the cppcms::session from the server side?
Again from reading the code the cppcms::sessions::session_storage class
provides methods to load and save session data. The garbage logic is inside
such a inherited class.
If the session data is stored on the server side and the cookie in the
browser only stores
the session key it should be possible to renew a cppcms::session.
And this is what I doing in this code snippet.
void session_interface::renew_session()
{
loaded_ = 0;
saved_ = 0;
load();
save();
}
If there is no way to "renew" the cppcms::session on the server side, I need to
add some js code to the client side doing silly gets to trigger the "renew" of
the cppcms::session.
thanks
--
Christian Gmeiner, MSc
|