English 中文(简体)
PHP 会话超时 ht访问文件
原标题:PHP session timeout htaccess file

Hi i m new to programming but am currently working on a session timeout problem. Basically my session keeps timing out even though i ve changed the session.gc_maxlifetime. I think another script using the same directory to store session data which doesn t have the maxlifetime set, is running and thus it ll use the shorter value instead. TO combat this i ve altered the htaccess file but it is still terminating after an 1hr 30mins, i need it to last for longer. My htaccess file is below. I ve looked at and tried many of the relevant posts on this board but nothing has worked so far. Any ideas would be greatly appreciated.

SetEnv PHPRC /home/rocket/public_html/php.ini

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

<IfModule mod_php5.c>
php_value session.save_path "new/username/php_sessions"
php_value session.gc_maxlifetime "86400"
php_value session.cookie_lifetime "86400"

</IfModule>


# END WordPress
问题回答

PHP不会用会话曲奇做你可能认为会话曲奇做的...

php_value 会话.gc_ 最大使用寿命“ 86400”

这只设定了垃圾收集 may 发生的时间,因为会话数据 < enge > 极小的可能性是在此之后收集的垃圾,这不太可能是罪魁祸首。

php_value 会话. cookie_ 寿命“ 86400”

这将设定会话 cookie 过期的时间... < 坚固> 但是 它在 session_start() 上没有更新, 因此, 如果您在一页开始会话时设定时钟键。 从页面移到页面不会重设“ 时钟 ”, 因此一个有600 < code> cookie_ liver time 的会话在开始 < 坚固 > 10分钟后将过期10分钟, 而不是在10分钟的不活动 < / 坚固 > - 您可能会看到这种行为 。

您的最佳赌注是设置 php_value session. cookie_ livertime "0" ,这意味着当用户关闭浏览器时会过期的会话 cookie < strong > only 。

如果您想要处理在一段时间不活动后触发的任意过期失效, 最好在 PHP 代码中这样做, 在会话中设置一个变量, 例如 $_SESSION[ 过期] , 并在每页开始时检查/ 更新/ 处理 。





相关问题
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 ...

热门标签