gwan redirection after create cookie

本秂侑毒 提交于 2019-12-13 18:16:09

问题


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 ?


回答1:


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.




回答2:


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')
}


来源:https://stackoverflow.com/questions/14886351/gwan-redirection-after-create-cookie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!