How do I set cookies using Perl CGI?

こ雲淡風輕ζ 提交于 2019-12-13 21:58:49

问题


I have tried without success setting cookies using Perl CGI.

My code looks like this:

$qry = new CGI

$cookie = $qry->cookie(-name=>'SERVER_COOKIE',
                       -value=>'USER_NAME',
                       -path=>'/'),
$qry->header(-cookie=>$cookie)

The page does not throw any error, but no cookie gets set!

I am using Firefox 3.5.5 with the add-on to view cookies.

What am i doing wrong?

Gath


回答1:


If your missing semicolons are just an artifact of pasting your question, the key point here is that you need to print the call to header for it to get sent to the browser.

print $qry->header(-cookie=>$cookie);


来源:https://stackoverflow.com/questions/1790194/how-do-i-set-cookies-using-perl-cgi

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