if (priv->kfile != NULL)
{
- g_key_file_set_value (priv->kfile, "SESSION", name, value);
+ if (value == NULL)
+ {
+ error = NULL;
+ if (!g_key_file_remove_key (priv->kfile, "SESSION", name, &error)
+ || error != NULL)
+ {
+ g_warning ("Unable to unset key «%s»: %s.",
+ name,
+ error != NULL && error->message != NULL ? error->message : "no details");
+ }
+ }
+ else
+ {
+ g_key_file_set_value (priv->kfile, "SESSION", 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 value tosession file: %s.",
+ g_warning ("Unable to write session file: %s.",
error != NULL && error->message != NULL ? error->message : "no details");
}
}
{
gchar *ret;
+ GError *error;
+
ZakCgiSessionPrivate *priv = ZAK_CGI_SESSION_GET_PRIVATE (session);
ret = NULL;
if (priv->kfile != NULL)
{
- ret = g_key_file_get_value (priv->kfile, "SESSION", name, NULL);
+ error = NULL;
+ ret = g_key_file_get_value (priv->kfile, "SESSION", name, &error);
+ if (error != NULL)
+ {
+ g_warning ("Unable to get session value «%s»: %s",
+ name,
+ error->message != NULL ? error->message : "noo details.");
+ }
}
return ret;
env = zak_cgi_main_get_stdin (zakcgimain);
ht_stdin = zak_cgi_main_parse_stdin (env, boundary[1]);
-
- zak_cgi_session_set_value (session, "user_name", (gchar *)g_value_get_string ((GValue *)g_hash_table_lookup (ht_stdin, "user")));
+ if (g_hash_table_lookup (ht_stdin, "reset") != NULL)
+ {
+ zak_cgi_session_set_value (session, "user_name", NULL);
+ }
+ else
+ {
+ zak_cgi_session_set_value (session, "user_name", (gchar *)g_value_get_string ((GValue *)g_hash_table_lookup (ht_stdin, "user")));
+ }
g_free (env);
g_strfreev (boundary);
}
else
{
- g_string_append (str, ", on the second page.");
+ g_string_append (str, ", on the second page.<br/><br/>");
+ g_string_append (str,
+ "<form action=\"/cgi-bin/session\" method=\"post\" enctype=\"multipart/form-data\">\n"
+ "<input type=\"submit\" name=\"reset\" value=\"Reset\" />\n"
+ "</form>\n");
}
g_free (method);
}