Flash 导致会话数据丢失
我正在使用 Flash uploader(uploadify, swfupload) 和 CodeIgniter,想要获取会话数据。我发现闪存不发送会话数据,所以我设置了 $config['sess_match_useragent'] = FALSE;
现在例如我设置了会话值 myname
在会话中,我可以使用 Internet Explorer 在我的后端 PHP 脚本上获取它。 :
Array
(
[session_id] => f4l82aa3f82rd4b2ed682e0e132d7a72
[ip_address] => 127.0.0.1
[user_agent] => Shockwave Flash
[last_activity] => 1310546544
[myname] => test
)
但问题是它仅在Internet Explorer上运行良好。在 Internet Explorer 上,session_id
在使用 Flash 之前和之后保持不变。 但在 Firefox 和所有其他浏览器上,session_id
已更改,我只能获取 session_id、ip_address、user_agent、last_activity BUT 而不是 myname
。
Array
(
[session_id] => c2cafff6daadc5148e6646s8c4c2aafa
[ip_address] => 127.0.0.1
[user_agent] => Shockwave Flash
[last_activity] => 1310548338
)
通过浏览和询问之前关于SO的问题,我发现由于Flash删除了会话数据,我应该将当前的会话ID发送到后端脚本,然后使用该会话ID恢复会话。所以我使用原始会话 ID 设置 session_id。
$original_session_id = $_REQUEST['session_id'];
$newdata = array(
'session_id' => $original_session_id,
);
$this->session->set_userdata($newdata);
现在我可以看到会话ID已成功设置,并且与之前相同,但问题是我仍然无法获取其他会话数据,例如myname
。为什么会这样呢?我不应该得到它吗,因为现在我的 session_id
是相同的。会话数据去了哪里?我现在如何检索它?
I'm using Flash uploader(uploadify, swfupload) with CodeIgniter, want to get the session data. I have found out that the flash does not send the session data, so I have set $config['sess_match_useragent'] = FALSE;
Now for example i have set session value myname
in session and I can get it on my backend PHP script using Internet Explorer. :
Array
(
[session_id] => f4l82aa3f82rd4b2ed682e0e132d7a72
[ip_address] => 127.0.0.1
[user_agent] => Shockwave Flash
[last_activity] => 1310546544
[myname] => test
)
But the problem is that it works fine ONLY on Internet Explorer. On Internet Explorer, the session_id
remains same before and after using flash.
But on the Firefox and all other browsers, the session_id
is Changed and I can get only session_id, ip_address, user_agent, last_activity BUT not myname
.
Array
(
[session_id] => c2cafff6daadc5148e6646s8c4c2aafa
[ip_address] => 127.0.0.1
[user_agent] => Shockwave Flash
[last_activity] => 1310548338
)
By browsing and asking the previous questions on SO, I found out that since the Flash deletes the session data, I should send the current Session ID to the backend script and then restore the session using that session ID. So I am setting the session_id using original session ID.
$original_session_id = $_REQUEST['session_id'];
$newdata = array(
'session_id' => $original_session_id,
);
$this->session->set_userdata($newdata);
Now I can see that the session ID is set successully and it is same as previous, but the problem is that I still can not get the other session data, such as myname
. Why is that so? Shouldnt I get it because now my session_id
is same. Where does the session data goes and how can I retrieve it now?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
session_id()
重新打开会话,如下所示...You could reopen the session using
session_id()
as follows...