选项卡式浏览和会话 [英] Tabbed browsing and sessions

查看:66
本文介绍了选项卡式浏览和会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否正确地假设当我从一个浏览器连接时,使用几个

选项卡到mysql / php / apache中生成的数据库只使用一个会话

所有标签?我一直在从我的数据库中删除记录并且我最好的猜测

是每个选项卡不是单独的会话,因此会话变量

由所有选项卡共享,不幸的是这个当我尝试使用我创建的表单来更新我的数据库时,会破坏。


无论如何,强制每个标签都有一个单独的会话,如果那是我的

问题?我的应用程序写的没有意识到这个潜在的问题

而且我对如何修复它感到有些困惑。至少我是唯一的用户,所以我知道不要打破它。


:-(


Pete

-
http://www.petezilla .co.uk

Am I right in assuming that when I connect from one browser, using several
tabs to a database produced in mysql/php/apache only uses one session for
all tabs? I have been loosing records from my database and my best guess
is that each tab is not a separate session, therefore the session variables
are shared by all tabs and unfortunately this plays havoc when I try to
update my database using the forms I have created.

Is there anyway to force each tab to have a separate session, if that is my
problem? My application was written not realising this potential problem
and I am a bit stumped on how to fix it. At least I am the only user so I
know not to break it.

:-(

Pete
--
http://www.petezilla.co.uk

推荐答案

Peter Chant< pe ** @ petezilla.co.uk>写道:
Peter Chant <pe**@petezilla.co.uk> wrote:
无论如何强制每个标签都有一个单独的会话,


编号对于服务器而言,标签对于服务器来说并不特别。

如果是这样的话是我的问题?


不,问题是你的应用程序没有线程安全。

我的应用程序写的没有意识到这个潜力问题和我有点难以理解如何修复它。
Is there anyway to force each tab to have a separate session,
No. Tabs are nothing special in anyway to the server.
if that is my problem?
No, the problem is that your application isn''t "thread safe".
My application was written not realising this potential problem and I
am a bit stumped on how to fix it.




不要使用会话将变量存储在全局范围中。你提到了
提到的表格,所以你可以为每个表单生成随机ID,并使用

存储该表单的sessionvars:



Don''t use the session to store variables in a "global scope". You
mentioned forms, so you could generate random IDs per form and use that
to store the sessionvars for that form:


_SESSION [''formid_foo''] [''foo''] =''foo'';
_SESSION[''formid_foo''][''foo'']=''foo'';


_SESSION [''formid_bar''] [''foo''] =''bar'';

_SESSION[''formid_bar''][''foo'']=''bar'';


这篇关于选项卡式浏览和会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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