#include <config.h>
#endif
+#include <stdlib.h>
+
+ #include <sys/stat.h>
+ #include <syslog.h>
+
++
+ #include <glib/gstdio.h>
#include <gio/gio.h>
#include <string.h>
const gchar *path,
gint minutes)
{
- GHashTable *ht_cookies;
-
GDateTime *gdt_now;
+ GDateTime *gdt_exp;
ZakCgiSession *zak_cgi_session;
ZakCgiSessionPrivate *priv;
{
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);
}
}