drtkyykai004574380 2009-08-03 00:35
浏览 332
已采纳

如何在php中注销用户?

Currently, in my php script, after an user logged in, i stored session_login = 1. But I have a problem. I have a habit in using firefox, multi-tab (i believe most people and all today web browsers app have multi-tab function). I closed the tab that has the session, but I didnt closed the browser. After few hours, I come back on the same page that require me to login, but it doesn't. It does not require me to login again(I think thats called "Session"). Is there anyway to logout the user if he close the tab instead close the browser??

I have 1 solution right now, time-idle kick out. But, I have very limited knowledge in date/time thing in php, so this would be the last option. I wanted to know, is there anything else i can do, beside using time-idle?

  • 写回答

5条回答 默认 最新

  • donglian3061 2009-08-03 00:42
    关注

    PHP has an easy way to set how long a session will last before it times out:

    session_set_cookie_params(3600); // make it expire after 1 hour
    

    Just pass it the number of seconds you want the session to last (in the example, 1 hour = 60 minutes = 3600 seconds).

    http://us2.php.net/manual/en/function.session-set-cookie-params.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部