[Cppcms-users] About exposed cookie management
Brought to you by:
artyom-beilis
From: redred77 <red...@gm...> - 2015-12-24 17:34:36
|
Hi I'm testing cppcms, and stuck with cookie management. This is sample code I'm using. session().set("test", "testvalue"); session().expose("test"); I could see the cookie exposed like "(prefix)_test". Also, I could see main encrypted session cookie which contains all info. It works as intended but when main session expires, things not work as I expected. "test" key is gone away since main session cookie was invalid anymore, but exposed "test" cookie key was still alive and transferred between client and server. 1. Is it right behaviour? Or have I misconfigured something? I thought that session() in cppcms guarantees the lifecycle of "main session key" and "exposed cookie" together. When session key is invalid anymore, I thought cookie would be deleted too. I quite don't know the mechanism underlying cppcms, so I want to know if I'm doing right. 2. Actually, it's not a big problem because I can check "test" key from session and invalidate from server. Currently, I'm deleting exposed cookie key like this. if (!session().is_set("test")) { session().set("test", ""); session().expose("test"); } When there's no valid "test" key in session, it makes that key with empty string and expose it. I tried many other methods, like hide(), clear(), but only this worked when previous session already expired. I feel like I'm doing in inefficient way. I don't know simpler api from cppcms. Can anybody suggest better api or approach for deleting plain cookie from cppcms? Thanks. |