From: Andrea Zagli Date: Sat, 21 May 2016 07:20:36 +0000 (+0200) Subject: Conflict on merge branch 'develop' into form_libzakform X-Git-Tag: v0.1.0~3^2 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=b9d816905923b9ed86f053f0807af48bd27ddda1;p=libzakcgi Conflict on merge branch 'develop' into form_libzakform --- b9d816905923b9ed86f053f0807af48bd27ddda1 diff --cc src/session.c index 7d9d3f4,87391d4..aa8d0bc --- a/src/session.c +++ b/src/session.c @@@ -20,8 -20,10 +20,13 @@@ #include #endif +#include + + #include + #include + ++ + #include #include #include @@@ -126,7 -124,10 +131,8 @@@ ZakCgiSessio const gchar *path, gint minutes) { - GHashTable *ht_cookies; - GDateTime *gdt_now; + GDateTime *gdt_exp; ZakCgiSession *zak_cgi_session; ZakCgiSessionPrivate *priv; @@@ -248,49 -253,11 +259,50 @@@ zak_cgi_session_set_value_full (ZakCgiS { ZakCgiSessionPrivate *priv = ZAK_CGI_SESSION_GET_PRIVATE (session); + GError *error; + if (priv->kfile != NULL) { - g_key_file_set_string (priv->kfile, "SESSION", name, value); - g_key_file_save_to_file (priv->kfile, g_file_get_path (priv->gfile), NULL); + if (name == NULL) + { + error = NULL; + if (!g_key_file_remove_group (priv->kfile, group, &error) + || error != NULL) + { + g_warning ("Unable to unset key «%s» in group «%s»: %s.", + name, + group, + error != NULL && error->message != NULL ? error->message : "no details"); + } + } + else + { + if (value == NULL) + { + error = NULL; + if (!g_key_file_remove_key (priv->kfile, group, name, &error) + || error != NULL) + { + g_warning ("Unable to unset key «%s» in group «%s»: %s.", + name, + group, + error != NULL && error->message != NULL ? error->message : "no details"); + } + } + else + { + g_key_file_set_string (priv->kfile, group, name, value); + } + } + + error = NULL; + if (!g_key_file_save_to_file (priv->kfile, g_file_get_path (priv->gfile), &error) + || error != NULL) + { + g_warning ("Unable to write session file: %s.", + error != NULL && error->message != NULL ? error->message : "no details"); + } + g_chmod (g_file_get_path (priv->gfile), S_IRUSR | S_IWUSR); } }