是不是使用“Header('Location:xxx')"”保留了会话变量? [英] Aren't session variable preserved using "Header('Location: xxx')"?

查看:87
本文介绍了是不是使用“Header('Location:xxx')"”保留了会话变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些信息传递到我网站上的另一个页面。我设置了

" session_start()"在第1页中,将会话变量分配给一个值,然后

执行一个header(''Location:....'')。但是在目标页面上,我没有得到任何会话变量值的
!顺便说一句,我在

位置标题中使用了相对位置,而不是绝对URL。这个行为看起来好像开始了

另一个会话,但它不应该有。


想法?


TIA ,


拉里伍兹

I am trying to pass some info to another page on my site. I set
"session_start()" in page 1, assign a session variable to a value, then
execute a "header(''Location: ....'')." But on the target page I don''t get
any session variable values! BTW, I used a relative location in the
Location header, not an absolute URL. The behavior looks like it started
another session, but it should not have.

Ideas?

TIA,

Larry Woods

推荐答案

" lwoods" < LA *** @ lwoods.com>在消息中写道

新闻:RPqzf.8953
"lwoods" <la***@lwoods.com> wrote in message
news:RPqzf.8953


JT.6285@fed1read06 ...
JT.6285@fed1read06...
我试图传递一些信息到我网站上的另一个页面。我设置了
session_start()在第1页中,将会话变量分配给一个值,然后执行一个header(''Location:....'')。但是在目标页面上我没有得到任何会话变量值!顺便说一下,我在
Location头中使用了相对位置,而不是绝对URL。行为看起来像是开始了另一个会话,但它不应该有。

想法?


在标题之前(location:),调用session_write_close()。


这给了我一些严重的麻烦基于浏览器挂起。

可怕的东西:)


哦,你应该总是使用带位置的绝对URL。相对的人会工作,但这并不能保证。你可以制作一个这样的函数来

为你处理:


函数反弹(
I am trying to pass some info to another page on my site. I set
"session_start()" in page 1, assign a session variable to a value, then
execute a "header(''Location: ....'')." But on the target page I don''t get
any session variable values! BTW, I used a relative location in the
Location header, not an absolute URL. The behavior looks like it started
another session, but it should not have.

Ideas?
Before the header("location: "), call session_write_close().

That gave me some serious headaches with mac-based browsers hanging.
Terrible stuff :)

Oh, and you should always use absolute URLs with location. Relative ones do
work, but that''s not guaranteed. You could make a function like this to
take care of that for you:

function bounce(


url ){

if(sustr(
url) {
if (sustr(


这篇关于是不是使用“Header('Location:xxx')&quot;”保留了会话变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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