处理会话超时和丢失的MemberID [英] Handle Session Timeout And Lost MemberID

查看:52
本文介绍了处理会话超时和丢失的MemberID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,一旦用户登录,我将他们的MemberID存储在global.asa文件中的全局变量中。


然后在其他页面中,我通过查看此变量找出我正在处理的成员

,即:


<%

私有lgMemberID


lgMemberID = Session.Contents(" MemberID")


%>


然后我使用这个变量来查询数据库...


Sub WriteMessages()

Dim strFirstName

Dim strSurname

Dim bPhone

昏暗的bCard

昏暗的bEMail

Dim strSQL

Dim rs


strSQL =" {CALL qGetMessages("& lgMemberID&")}"


设置rs = Server.CreateObject(" ADODB.Recordset")

rs.Open strSQL,conn,3


直到rs.EOF

strFirstName = rs(" ContactFirstName")

strSurname = rs( ContactSurname)

bPhone = rs(" Phone")

bCard = rs(" Card")

bEMail = rs (电子邮件)


回复

。写入<< TR>" &安培; vbcr

。写入"< TD width = 160>" &安培; strFirstName& " " &安培; strSurname&

"< / TD>" &安培; vbcr

。写入"< TD align =''center''width = 100>"

如果是bPhone那么.Write"< IMG SRC =' 'images / yes.gif''ALT =''''BORDER = 0>"

。写"< / TD>" &安培; vbcr

。写入"< TD align =''center''width = 100>"

如果是bCard那么。写<< IMG SRC =' 'images / yes.gif''ALT =''''BORDER = 0>"

。写"< / TD>" &安培; vbcr

。写入"< TD align =''center''width = 100>"

如果bEMail则.Write"< IMG SRC =' 'images / yes.gif''ALT =''''BORDER = 0>"

。写"< / TD>" &安培; vbcr

。写入"< TD width = 23>< A HREF =''http://?''>编辑< / A>< / TD>" &安培; vbcr

。写入"< TD width = 23>< A HREF =''http://?''>删除< / A>< / TD>" &安培; vbcr

。写入"< / TR>" &安培; vbcr

结束

rs.MoveNext

循环


rs.Close

设置rs = Nothing


结束子

我想知道如何专业地处理
session。

当应用程序。超出Session.Contents(MemberID)

等于0.

这意味着我收到错误:


" ; ADODB.Field(0x800A0BCD)

BOF或EOF为True,或当前记录已删除。

请求的操作需要当前记录。


我真的不想直接处理BOF / EOF错误,因为这只是一个不同问题的症状(超时)。


我是否必须强迫用户再次登录?

增加超时时间?

其他人如何做到这一点?


我也不知道将超时时间增加到多少是合适的,

比如2小时。当网站产生大量流量时,

保持100次会话活动这么长时间会吃掉太多

资源。


其他人是否使用cookie来存储memberID而不是会话

变量?

如果是这样的话 - 他们对那些阻止cookie的人做了什么? />

***通过开发人员指南 http://www.developersdex发送。 com ***

不要只是参加USENET ......获得奖励!

解决方案

" Edward Rothwell" < ED ************* @ hale-it.co.uk>在留言中写道

新闻:%2 **************** @ tk2msftngp13.phx.gbl ...

我有一个用户登录后的网站我将他们的MemberID存储在global.asa文件中的全局变量中。

然后在其他页面中我找到了我正在处理的成员<看看这个变量,即:


如果IsEmpty(lgMemberId)那么

....超时

Else


增加超时可能会解决这个问题,但是如果你处理了很多用户,那么你应该避免浪费大量的资源。

<%
私人lgMemberID

lgMemberID = Session.Contents(" MemberID")

%>
然后我用这个变量来查询数据库...

Sub WriteMessages()
Dim strFirstName
Dim strSurname
Dim bPhone
Dim bCard <昏暗的bEMail
昏暗的strSQL


strSQL =" {CALL qGetMessages(& lgMemberID&&qu) ot;)}"

设置rs = Server.CreateObject(" ADODB.Recordset")
rs.Open strSQL,conn,3,3

直到rs.EOF
strFirstName = rs(" ContactFirstName")
strSurname = rs(" ContactSurname")
bPhone = rs(" Phone")
bCard = rs(卡片)
bEMail = rs(电子邮件)

响应
。写< TR> &安培; vbcr
。写< TD width = 160> &安培; strFirstName& " " &安培; strSurname&
"< / TD>" &安培; vbcr
。写< TD align =''center''width = 100>"
如果是bPhone那么.Write"< IMG SRC =''images / yes.gif'' ALT =''''BORDER = 0>"
.Write"< / TD>" &安培; vbcr
。写< TD align =''center''width = 100>"
如果bCard然后。写<< IMG SRC =''images / yes.gif'' ALT =''''BORDER = 0>"
.Write"< / TD>" &安培; vbcr
。写< TD align =''center''width = 100>"
如果是bEMail那么.Write"< IMG SRC =''images / yes.gif'' ALT =''''BORDER = 0>"
.Write"< / TD>" &安培; vbcr
。写入<< TD width = 23>< A HREF =''http://?''>编辑< / A>< / TD>" &安培; vbcr
。写入<< TD width = 23>< A HREF =''http://?''>删除< / A>< / TD>" &安培; vbcr
。写< / TR> &安培; vbcr
结束
rs.MoveNext
循环

rs.Close
设置rs = Nothing

End Sub

我想知道如何专业地处理
会话的超时。
在应用程序的那一刻。超时Session.Contents(MemberID)
等于0.
这意味着我收到错误:

ADODB.Field(0x800A0BCD)
BOF或EOF为True,或者当前记录已被删除。
请求的操作需要当前记录。

我真的不想直接处理BOF / EOF错误因为这只是一个不同问题的症状(超时)。

我是否必须强迫用户再次登录?
增加超时时间?
其他人如何做到这一点??

我也没有看到将超时延长到2小时是多么合适。当网站产生大量流量时,那么长时间保持100次会话会占用太多的资源。

其他人使用cookie来存储memberID而不是一个会话
变量?
如果是这样 - 他们对那些阻止cookie的人做了什么?

***通过Developersdex发送 http://www.developersdex.com ***
不要只是参加USENET ...奖励它!




Edward Rothwell在2004年12月6日写的

microsoft.public.inetserver.asp .general:

我有一个网站,一旦用户登录,我将他们的MemberID存储在global.asa文件的全局变量中。




不可能。


Global.asa仅在服务器重置或开机后第一次接触时运行。


Global.asa在此之后完成并且所有变量都随之消失。


当用户登录时,Global.asa不会再次运行。


但是当用户启动一个新会话时,session-onstart子运行,并且即使在那里也是
,子中没有持久变量。


也许你的意思是应用程序变量或会话变量?

这些不需要Global.asa来运行。


Evertjan。


" Evertjan"。 <前************** @ interxnl.net>在消息中写道

news:Xn ******************** @ 194.109.133.29 ...

Edward Rothwell于2004年12月6日在
microsoft.public.inetserver.asp.general写道:

我有一个网站,一旦用户登录我存储
他们的MemberID在global.asa文件中的全局变量中。

不可能。

Global.asa仅在服务器重置或启动后的第一次联系上运行。




我认为他当然使用Session_onStart这是解决方案,但

你 - 无论如何 - 获得此事件,确实,在登录后例如.asp页面。

Global.asa在此之后完成,所有变量都随之消失。

当用户登录时,Global.asa不会再次运行。

但是当用户启动一个新会话时,session-onstart子程序运行,即使在那里,子程序中也没有持久变量。

也许你的意思是应用程序变量或sessi变量?
这些不需要Global.asa来运行。

Evertjan。




I have a web site where once a user has logged on I store
their MemberID in a global variable in the global.asa file.

Then in other pages I find out which member I am dealing
with by looking at this variable, ie:

<%
Private lgMemberID

lgMemberID = Session.Contents("MemberID")

%>

I then use this variable to query a database...

Sub WriteMessages()
Dim strFirstName
Dim strSurname
Dim bPhone
Dim bCard
Dim bEMail
Dim strSQL
Dim rs

strSQL = "{CALL qGetMessages (" & lgMemberID & ")}"

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, conn, 3, 3

Do Until rs.EOF
strFirstName = rs("ContactFirstName")
strSurname = rs("ContactSurname")
bPhone = rs("Phone")
bCard = rs("Card")
bEMail = rs("EMail")

With Response
.Write "<TR>" & vbcr
.Write "<TD width=160>" & strFirstName & " " & strSurname &
"</TD>" & vbcr
.Write "<TD align=''center'' width=100>"
If bPhone Then .Write "<IMG SRC=''images/yes.gif'' ALT='''' BORDER=0>"
.Write "</TD>" & vbcr
.Write "<TD align=''center'' width=100>"
If bCard Then .Write "<IMG SRC=''images/yes.gif'' ALT='''' BORDER=0>"
.Write "</TD>" & vbcr
.Write "<TD align=''center'' width=100>"
If bEMail Then .Write "<IMG SRC=''images/yes.gif'' ALT='''' BORDER=0>"
.Write "</TD>" & vbcr
.Write "<TD width=23><A HREF=''http://?''>Edit</A></TD>" & vbcr
.Write "<TD width=23><A HREF=''http://?''>Delete</A></TD>" & vbcr
.Write "</TR>" & vbcr
End With
rs.MoveNext
Loop

rs.Close
Set rs = Nothing

End Sub
I want to know how to professionally handle the ''time-out'' of the
session.
At the moment when the app. times out Session.Contents("MemberID")
equals 0.
Which means I get an error:

"ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record."

I don''t really want to handle the BOF/EOF error directly as this is just
a symptom of a different problem (the time out).

Would I have to force the user to log in again?
Increase the time out?
How do other people do this??

I also don''t see how appropriate it would be to increase the timeout to,
say 2 hours. When the site generates large amounts of traffic then
keeping 100s of sessions live for so long is going to eat too many
resources.

Do other people use cookies to store the memberID instead of a session
variable?
If so - what do they do about people who have cookies blocked?

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!

解决方案

"Edward Rothwell" <ed*************@hale-it.co.uk> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

I have a web site where once a user has logged on I store
their MemberID in a global variable in the global.asa file.

Then in other pages I find out which member I am dealing
with by looking at this variable, ie:
If IsEmpty(lgMemberId) Then
.... timeout
Else

Increasing the timeout might fix this but if you deal with lots of users,
you should avoid to waste lots of resources.
<%
Private lgMemberID

lgMemberID = Session.Contents("MemberID")

%>

I then use this variable to query a database...

Sub WriteMessages()
Dim strFirstName
Dim strSurname
Dim bPhone
Dim bCard
Dim bEMail
Dim strSQL
Dim rs

strSQL = "{CALL qGetMessages (" & lgMemberID & ")}"

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, conn, 3, 3

Do Until rs.EOF
strFirstName = rs("ContactFirstName")
strSurname = rs("ContactSurname")
bPhone = rs("Phone")
bCard = rs("Card")
bEMail = rs("EMail")

With Response
.Write "<TR>" & vbcr
.Write "<TD width=160>" & strFirstName & " " & strSurname &
"</TD>" & vbcr
.Write "<TD align=''center'' width=100>"
If bPhone Then .Write "<IMG SRC=''images/yes.gif'' ALT='''' BORDER=0>"
.Write "</TD>" & vbcr
.Write "<TD align=''center'' width=100>"
If bCard Then .Write "<IMG SRC=''images/yes.gif'' ALT='''' BORDER=0>"
.Write "</TD>" & vbcr
.Write "<TD align=''center'' width=100>"
If bEMail Then .Write "<IMG SRC=''images/yes.gif'' ALT='''' BORDER=0>"
.Write "</TD>" & vbcr
.Write "<TD width=23><A HREF=''http://?''>Edit</A></TD>" & vbcr
.Write "<TD width=23><A HREF=''http://?''>Delete</A></TD>" & vbcr
.Write "</TR>" & vbcr
End With
rs.MoveNext
Loop

rs.Close
Set rs = Nothing

End Sub
I want to know how to professionally handle the ''time-out'' of the
session.
At the moment when the app. times out Session.Contents("MemberID")
equals 0.
Which means I get an error:

"ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record."

I don''t really want to handle the BOF/EOF error directly as this is just
a symptom of a different problem (the time out).

Would I have to force the user to log in again?
Increase the time out?
How do other people do this??

I also don''t see how appropriate it would be to increase the timeout to,
say 2 hours. When the site generates large amounts of traffic then
keeping 100s of sessions live for so long is going to eat too many
resources.

Do other people use cookies to store the memberID instead of a session
variable?
If so - what do they do about people who have cookies blocked?

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!




Edward Rothwell wrote on 06 dec 2004 in
microsoft.public.inetserver.asp.general:

I have a web site where once a user has logged on I store
their MemberID in a global variable in the global.asa file.



Impossible.

Global.asa only runs on the first contact after server reset or power up.

Global.asa is done after that and all the variables die with it.

When a user logs in, Global.asa does not run again.

But when a user starts a new session, the session-onstart sub runs, and
even there, there are no persistent variables in a sub.

Perhaps you mean a application variable or a session variable?
These do not need Global.asa to run.

Evertjan.


"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...

Edward Rothwell wrote on 06 dec 2004 in
microsoft.public.inetserver.asp.general:

I have a web site where once a user has logged on I store
their MemberID in a global variable in the global.asa file.

Impossible.

Global.asa only runs on the first contact after server reset or power up.



I think he, of course, uses Session_onStart which is the solution, but
you -never- get this event, indeed, after a login.asp page for instance.
Global.asa is done after that and all the variables die with it.

When a user logs in, Global.asa does not run again.

But when a user starts a new session, the session-onstart sub runs, and
even there, there are no persistent variables in a sub.

Perhaps you mean a application variable or a session variable?
These do not need Global.asa to run.

Evertjan.




这篇关于处理会话超时和丢失的MemberID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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