查看: 813|回复: 16
|
LOGOUT 的问题。。。棘手
[复制链接]
|
|
我有一个web browser....
如果要每次让人按 logout button 有人会忘记。。。
我要通过 browser 上方的 "X"
when browser close, i want to set the session to null....
any idea.. |
|
|
|
|
|
|
|
发表于 21-11-2005 10:46 AM
|
显示全部楼层
setcookie("cookie_value",$value);
这是PHP的. |
|
|
|
|
|
|
|

楼主 |
发表于 21-11-2005 12:23 PM
|
显示全部楼层
USING JSP.....
do u hav other way since some user dun allow cookie...
althought this is a solution....
plz provide me with another solution |
|
|
|
|
|
|
|
发表于 21-11-2005 12:28 PM
|
显示全部楼层
原帖由 Imnotsad 于 21-11-2005 12:23 PM 发表
USING JSP.....
do u hav other way since some user dun allow cookie...
althought this is a solution....
plz provide me with another solution
那么就使用Database Session吧!
- Login 后Create一个Session ID, 把需要用来Identify的资料存放在Database.
- 每一个Link或Form Post 都Append Session ID, 如 &session_id=<%=session_id%>, <input name=session_id type=hidden value="<%=session_id">"> |
|
|
|
|
|
|
|

楼主 |
发表于 21-11-2005 01:42 PM
|
显示全部楼层
plz read the title..
i am using database session actually...
i have a link "log out" and the database session is set to null,
but when i closing the website clicking the "X" instead of the link...
it doesnt set the session to null
- function logout(){
- if(window.close()){
- alert('you have logged out');
- setSession("null"); //something like this..
- }
- }
复制代码 |
|
|
|
|
|
|
|
发表于 21-11-2005 02:24 PM
|
显示全部楼层
原帖由 Imnotsad 于 21-11-2005 01:42 PM 发表
plz read the title..
i am using database session actually...
i have a link "log out" and the database session is set to null,
but when i closing the website clicking the "X&quo ...
如果你是用Database Session的话当直接关掉Browser的时候Session ID就已经Loss了.不需要这样做.
但是不敢保证URL会不会Cache着History .
如果真的要这样的话那么就用
<script>
function logout(){
window.open('logout.jsp','','xxxx');
}
</script>
<body onunload="logout()">
在Logout.jsp的最后一行加上
self.close();
试试看行不行得通. |
|
|
|
|
|
|
|
发表于 22-11-2005 09:31 AM
|
显示全部楼层
建议你配合SERVLET来建立你的网站。我们是在filter方面控制的。 |
|
|
|
|
|
|
|

楼主 |
发表于 22-11-2005 08:25 PM
|
显示全部楼层
can we filter thru the struts |
|
|
|
|
|
|
|
发表于 23-11-2005 09:07 AM
|
显示全部楼层
我沒有用cookie,只单用session做JSP网页而已。
按x后就session就关了,第二次连线就要重新login。 |
|
|
|
|
|
|
|
发表于 23-11-2005 09:50 AM
|
显示全部楼层
这就是Web application的坏处。
如果你是用Session 的话,在一定时间内没人用Server request,
这Session会自己断。在IIS是20分钟,你可以自己设的。
除非是Cookies可以知道你关Browser,因为Cookies是在Client的,
而Session是在Server的。
这就是用Session的缺点之一。 |
|
|
|
|
|
|
|

楼主 |
发表于 23-11-2005 11:36 AM
|
显示全部楼层
原帖由 bp.net 于 23-11-2005 09:50 AM 发表
这就是Web application的坏处。
如果你是用Session 的话,在一定时间内没人用Server request,
这Session会自己断。在IIS是20分钟,你可以自己设的。
除非是Cookies可以知道你关Browser,因为Cookies是在Clien ...
what u say is right...which ppl using , they set around 30 minutes.
but sometimes user want to relogin again...
after 5 minutes maybe....
the problem is the closing not thru logout button but, clicking the 'X' to close........
servlet filter only redirect ppl to logout page right....
when we close using 'X' the session cannot set to null |
|
|
|
|
|
|
|
发表于 23-11-2005 01:23 PM
|
显示全部楼层
session 他自己会time out。然后不见。
你不用担心这个的。
如果它直接click "X" 然后再开过的时候也是要login过的。
就算session还没有time out。
为什么会这样呢?
因为,每一次那个session 自己create的id也就是server自己create的都会不一样的。
所以没有事的。
除非你用cookie。
好像cari这样。
(如有错,请指出,大家都是学习的) |
|
|
|
|
|
|
|
发表于 23-11-2005 02:04 PM
|
显示全部楼层
我想说的是,应该没办法可以Set成Null。
另一方面是,也没这个必要吧? |
|
|
|
|
|
|
|
发表于 24-11-2005 02:20 AM
|
显示全部楼层
原帖由 红发 于 23-11-2005 01:23 PM 发表
session 他自己会time out。然后不见。
你不用担心这个的。
如果它直接click "X" 然后再开过的时候也是要login过的。
就算session还没有time out。
为什么会这样呢?
因为,每一次那个session ...
session 就是cookie 的一种.
没有小心的处理会很容易被人用SID injections和你玩耍 |
|
|
|
|
|
|
|

楼主 |
发表于 24-11-2005 09:03 AM
|
显示全部楼层
my session is set in database..it need to reset..it |
|
|
|
|
|
|
|
发表于 24-11-2005 09:27 AM
|
显示全部楼层
原帖由 Imnotsad 于 24-11-2005 09:03 AM 发表
my session is set in database..it need to reset..it
在session 里放一个last_update, 在 n 分钟内没有update 就把它 clear 掉 |
|
|
|
|
|
|
|

楼主 |
发表于 25-11-2005 01:03 PM
|
显示全部楼层
原帖由 megablue 于 24-11-2005 09:27 AM 发表
在session 里放一个last_update, 在 n 分钟内没有update 就把它 clear 掉
this has been done it set to 30 minutes...
but after 5 minutes..user need to relogin again....
they dun want to wait...
wat can i do....
b4 closing the browser, fire an event to set the database... |
|
|
|
|
|
|
| |
本周最热论坛帖子
|