PDA

View Full Version : Cache proble


ebco
12-27-2002, 09:58 AM
Cache problem

I am maintaing one session in that after user enter username & password i am checking my condition with this code

if rs("cnt")<>0 then

Session("username")= username
Response.Redirect "logindone.asp"
else
Session("username")= ""
Response.Redirect "login.asp?msgid=0"
end if

on logindone.asp page i am giving this condition

username = session("username")

if username="" then
Session("username")= ""
Response.Redirect "login.asp"
end if

& on logoutpage

session("username")=""
Response.Redirect "login.asp"

if user hit the page logindone.asp through typing url in addressbar first time it redirect to login.asp
but after login & doing logout then if he type into url & hit the
logindone.asp he can enter the page but if i refresh it takes me to login.asp


Why this is happening can anybody tell me if they faced such type of proble? Is this a proble of cache?

raf
12-27-2002, 10:39 AM
First of all, your code contains some unnecessary line.
About cache: could be. You can find out easy by adding the time to that page

response.write(Time)


If you then type in the url, and the time is wrong, then the page was cached (server or clientsided)

To prevent caching, make the page expire immedately

Response.Expires 0

ebco
12-27-2002, 11:05 AM
I tried that also
if used that in my logout page if give me error of 500 & if i used in
logindone.asp then it's not affecting. only it redirects when i resh that page

so by that time is there any way to refresh the page at once only?

& thaks raf i tried it with
response.write(Time)
it's giving showing the same time

raf
12-27-2002, 11:24 AM
I'm not sure i understood that.

Displaying the time on your page should work. I'can't see why this should not work. It tells you wether the page got cached.

If the page is cached on the server, then the 'response.expires' will have no effect (because it only checks browser caching).

edit: had post open while ebco edited.

ebco
12-27-2002, 12:08 PM
I tried it with
Response.Expires = -1000

now it is working but still there problem when i am going with browser back it goes

raf
12-27-2002, 01:25 PM
what's the problem when you use backbutton ?

if you wan't prevent users from going back, i always set a session-variabe, just before my redirect + on the top of the page, i check for the value in that session variable. Like this:

if session("filled_in")=1 then
response.redirect("backerror.asp")
else
all your code
before redirect
session("filed_in")=1
response.redirect("the url")
end if


of coarse, you can't do this for every page. (or you should use a session-variable for each page) i only use it for smaller functionalitys, like a questionair or something.

if you want to prevent users from going back (in the history) you'll need to use Javascript to make something (buth not all browsers support that)