Flash 导致会话数据丢失

发布于 2024-11-19 16:45:35 字数 1447 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好倦 2024-11-26 16:45:35

您可以使用 session_id() 重新打开会话,如下所示...

session_id($original_session_id);
session_start();

$this->session->set_userdata($_SESSION);

You could reopen the session using session_id() as follows...

session_id($original_session_id);
session_start();

$this->session->set_userdata($_SESSION);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文