PDA

View Full Version : Can sumbody explain?


madg3rr
06-25-2003, 11:16 PM
Can anybody pls enlighten me on session? I dunno how dis is work or on how 2 use. Wad izit fer? I read on asp book but the explanation is not tad clear. Can sumbody pls kind enuf 2 gif me an explanation briefly and clearly? & show me how it is done? thanx...

jsawkang
06-26-2003, 01:25 AM
hi..

jsawkang
06-26-2003, 01:31 AM
hi..

Session normally is used if u want to stored the value of a variable or from form item and pass to another page or later use the value at some other page.

example of usage.
str=request.form("txtname")
Session("NAME")=str

if u want to retrive the value of "str" in any other webpage. u on need to put <%=Session("NAME")%>

if u want to set the session to nothing. use this
Session.Abandon

Session.abandon will set all session variable to nothing.

madg3rr
06-26-2003, 03:33 AM
hei thanx.. i can abit understand now.
so which means tad Session("NAME") can be use thru out our webpages. I see...

but wen do i use the session.abandon? lets say fer example. u log in usin the name den u store it in the Session("NAME"). but wen another user logs in den will it override the Session("NAME") or it will remain as it is?

den wad abt session.timeout? wad does it do actually?

jsawkang
06-26-2003, 07:40 AM
yes. if u login as different user, it'll be over written.

session.timeout if the time range that u want the session to last.
for example session.timeout=60

60= 1 hour i think. so after the time frame, the session will be released and set to nothing.

madg3rr
06-27-2003, 04:06 AM
i see... ok i understand oredi... ok last qns i think... heh! erm... i m practising wad u taught me & tryin out in diff methods. but dis one got prob... ok i haf 3 pages.... 1=login page, 2=display page, 3=logout page...

at the login page i declare the session to dis,
session("name")=rs.fields("name")

den at the display page
<%=Session("officer")%>

at the logout page dis
Session.Abandon

the prob is tad lets say i log out frm the system as Sally. it shud clear the session("name") rite? but den wen i log in as Harry, the display page does nt show me Harry instead it shows me Sally.

i dunno why is dis so. i tried a test at the logout page and insert dis...
response.write session("officer")
Session.Abandon

dis test gives me Harry. Dis is wierd... The display page shows me Sally while the logout page shows me Harry... Kinda funny actually... Can u pls explain why is dis so? Or i did sumthing wrong?

jsawkang
06-29-2003, 06:23 AM
hi...

ur problem is very abvious there.
in the login page u declared session("name")=rs.fields("name")
but in the display page u try the display <%=Session("officer")%>

if u wanted to display the person that have login, u should put <%=session("name")%> instead of <%=Session("officer")%>.

good luck