English 中文(简体)
如何知道某届会议是否仍然有效?
原标题:How can i know if a session is still active or not?
  • 时间:2011-07-07 09:59:24
  •  标签:
  • php
  • session

I m storing the sessions ids in a database table. I want to run a script that reads from the table every session id and check if this session is active or not.

I know that session information is stored in a directory (/tmp by default) and removed from there when the session is closed. But if the user close his browser without disconnecting from the session the session file is still in the /tmp directory.

我如何知道届会是否仍然活跃?

I have searched the session functions and didn t find anything that could help.

问题回答

一般来说,唯一的方式是,在每届会议参考时,都要有一个“最后使用的”日期/时间,并在会议使用吨数后弃置/停用。

不可能说,如果会议在请求之间重新开放,仅仅在需要时提及,而且需要由不断疲软的客户决定,那么会议是否会被进一步提及。

如果你的会议是按其声音排列的,你可以使用最后查阅的个人档案,但有可能避免麻烦。

如果你在数据库中保留会议。 在数据库表中增加最后存取或经过修改的时间。 我在找回或储存会议资料的程序中加上了密码。 然而,长期以来,你想要的是你们的会议。 每一次,你都可以更新这一时间。 这似乎会造成业绩的冲击,但我已利用这一模式/进程,这是一个很大的尺度。 我几乎总是利用数据库储存会议信息。 请研究session_set_save_handler()。 我可以尝试从我利用的先前项目中收集一些我自己的法典,但我相信,阅读关于这一手册并推广执行将有助于你。

为什么你们会关注这一已经过时的会议? 在某些随机的时间里,他们将从临时夹中清除。

您应检查贵国数据库中最后的存取时间,如果能更确切地说出一些预先确定的时间,就会将其标记为死亡。

但是也想到你的表现。 它为把本届会议数据储存在memcache或类似于<>——只是将其储存在记忆中,而不是在非行。 详见:http://memcastal.org/

It s really easy to store your session data in memcached: http://www.dotdeb.org/2008/08/25/storing-your-php-sessions-using-memcached/

There isn t such a function. PHP itself use somewhat an hack to determine when a session is expired, there are several options into the php.ini configuration file.

In short, every time a session started there is a gc_probability/gc_divisor chanche that php will start a garbage collection of pending data. The session accessed before gc_maxlifetime seconds are considered expired and PHP deletes them.

You can relay on this behaviour tuning the envolved options or mimic this behaviour with a similar approach.

参考:





相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签