[Libcgi-general] cgi_add_cookie max_age - patch included
Brought to you by:
rafaelsteil
From: Martin R. <m....@gm...> - 2004-03-12 12:10:33
|
Hello, cgi_add_cookie with max_age didnn't work with IE 6.0 . I.E. requires expire=3DWdy, DD-Mon-YYYY HH:MM:SS GMT for the Lifetime. Here is a patch that works for me: --- orig/cookie.c Mon Dec 15 11:31:24 2003 +++ cookie.c Fri Mar 12 13:26:56 2004 @@ -22,6 +22,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> +#include <sys/time.h> =20 #include "error.h" #include "cgi.h" @@ -61,13 +63,22 @@ const char *domain,=20 const int secure) { + time_t curtime; + struct tm *brokentime; + char buffer[80]; if (headers_initialized) return 0; =20 printf("Set-cookie: %s=3D%s;", name, value); =20 if (max_age) - printf(" Max-age=3D%s;", max_age); + { + curtime=3Dtime(NULL)+atoi(max_age); + brokentime=3Dgmtime(&curtime); + strftime (buffer, 80, "%a, %d-%b-%Y %H:%M:%S", brokentime); + printf("expires=3D%s GMT;",buffer); +// printf(" Max-age=3D%s;", max_age); + } if (path) printf(" Path=3D%s;", path); if (domain) =20 =20 Viele Gr=FC=DFe, Martin --=20 Martin Raatz D-53783 Eitorf |