如何使用Perl CGI设置Cookie? [英] How do I set cookies using Perl CGI?

查看:610
本文介绍了如何使用Perl CGI设置Cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有成功使用Perl CGI设置Cookie。



我的代码如下所示:

  $ qry = new CGI 

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

页面不会引发任何错误,但是没有设置cookie!



我使用Firefox 3.5



Gath

p>

解决方案

如果你缺少的分号只是一个粘贴你的问题的工件,这里的关键是你需要打印调用,以便发送到浏览器。

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


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

解决方案

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);

这篇关于如何使用Perl CGI设置Cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆