{
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_value (priv->kfile, group, name, value);
++ 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");
+ }
}
}