1

For my form validation page, I'd like to create a cookie and be redirected to another page but that doesn't work. Redirection prevents the creation of cookie. Do you have any solution ?

Gil
  • 3,279
  • 1
  • 15
  • 25
John S
  • 231
  • 3
  • 11

2 Answers2

0

One way of doing it is on the landing page add a flag (Query Parameter) in there to tell it to create cookie.

http://domain/page?create_cookie=true

if create_cookie exist the landing page will create the cookie.

Richard Heath
  • 349
  • 3
  • 12
0

A way to proceed is to create the cookie from a G-WAN handler, bypassing the servlet or the automatically generated redirection, but you can also use this method:

#include "gwan.h" // G-WAN exported functions

int main(int argc, char *argv[])
{
   char redir[] = "Cookie: blah\r\n" // add a cookie in the response
                  "Location: 100.html\r\n\r\n";
   http_header(HEAD_ADD, redir, sizeof(redir) - 1, argv);

   return 301; // return an HTTP code (301:'Moved')
}
Gil
  • 3,279
  • 1
  • 15
  • 25