为什么我的刷新标题不起作用?
我正在使用 CGI.pm 模块在 Perl CGI 中完成家庭作业。在我的代码中,我正在检查 cookie。如果 cookie 存在,我想启动另一个 CGI 脚本。在其他情况下,我可以使用类似的代码,但在这种情况下,我只得到以下浏览器输出,而不是我正在寻找的重定向。
Refresh: 1; URL=homepage.pl.cgi
Content-Type: text/html; charset=ISO-8859-1
这是我的代码:
#get the cookie
my %SIDhash = cookie('SIDhash');
if ( exists $SIDhash{"SID"} ) {
print header(-refresh=>'0; homepage.pl.cgi');
}
我在这里不理解哪些基本原理?
谢谢, CB
I'm working on a homework assignment in Perl CGI using the CGI.pm module. In my code I am checking for a cookie. If the cookie exists, I want to initiate another CGI script. In other situations I was able to use similar code, but in this instance I merely get the following browser output, not the redirect that I was looking for.
Refresh: 1; URL=homepage.pl.cgi
Content-Type: text/html; charset=ISO-8859-1
Here's my code:
#get the cookie
my %SIDhash = cookie('SIDhash');
if ( exists $SIDhash{"SID"} ) {
print header(-refresh=>'0; homepage.pl.cgi');
}
What fundamentals am I not understanding here?
Thanks,
CB
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这应该可以解决问题:
如果您要在代码中的各个位置将标头分段组装,请首先将标头组件保存在变量中,例如:
This should do the trick:
If you are assembling the header in pieces, in various places in your code, save the header components in a variable first, e.g.:
我不确定为什么你的刷新不起作用,但听起来使用它会更合适:
只是一个想法。
I'm not sure why your refresh doesn't work, but it sounds like it would be more appropriate to use:
Just a thought.
尝试将行更改为
据我所知,现在应该是正确的。
维基百科上的此页面提供有关刷新和其他重定向方法的信息。
Try changing the line to
From what I can tell, this should be correct now.
This page on Wikipedia offers information on Refresh and other methods of redirection.