SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Location
    bangalore
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem in logout code

    Hai
    i developed
    login page,confirm page,logout page

    problem is when i clicked logout i redirect my user to home page
    but if i click back browser the previous pages are as such as it think it does nt expires,i used
    logout code is follows

    Session.Abandon ()
    Response.Redirect ("index.asp")

    how can i expires the account

    help me,i have attached login confirm code below

    Code:
    username=trim(request.form("username"))
    	password=trim(request.form("password"))
    
    		If username="" or password="" then
    			Response.redirect("login.asp?error=3")
    		end if
    	set objrs=server.createobject("ADODB.recordset")
    	my_sql="select username,password from user_list"
    	objrs.open my_sql,objconn,3,1
    
    	foundit=false
    		DO until objrs.EOF or foundit
    			if(strcomp(objrs("username"),username,vdtextcompare)=0)  then
    			foundit=true
    			else
    			objrs.movenext
    			end if
    		loop
    			if not foundit then
    			objrs.close
    			set objrs=nothing
    			objconn.close
    			set objconn=nothing
    				response.redirect("login.asp?error=1")
    			end if
    
    		if (strcomp(objrs("password"),password,vbtextcompare)=0) then
    	
    			response.write"welcome you have logged in as "&username&" "
    		else 
    			response.redirect("login.asp?error=2")
    			
    		end if
    %>

  2. #2
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here how you are maintaining session?
    Are you storing username or something in session variable??

    -SSJ

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Location
    bangalore
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no
    how can i store session variable
    please tell me
    regards
    sona

  4. #4
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use session variable as follows:

    response.write"welcome you have logged in as "&username&" "
    Session("UserName") = username

    Now You have to check the following condition in all the inside pages.
    If Session("UserName")<>"" then
    ' User Logged-In
    Else
    'User Not Logged-In
    'Should be redirect to login page
    End If


    -SSJ

  5. #5
    SitePoint Addict
    Join Date
    Jan 2007
    Posts
    344
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The session stuff is cookie based. So, you be sure you flush the cookie.

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I bet its caching...
    try adding
    Response.CacheControl = "no-cache"
    to the pages you are having problems with

  7. #7
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Location
    bangalore
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    i created session variable but ..

    hai
    i have created session variable and i displayed session name
    but still if i click back browser i can able to see tha previous pages
    i checked as follows

    Code:
    if (strcomp(objrs("password"),spassword,vbtextcompare)=0) then
    Session("IsLoggedIn") = "yes"
         Session("strusername") = objrs("username")
    my logout code
    [coed]
    <%
    Session.Abandon
    Session("IsLoggedIn") = "no"
    Response.Redirect ("index.asp")
    %>
    [/code]

    in all my authentiacted pages how can i check where i have to check the login session

    please help me

  8. #8
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let me explain you the whole procedure:
    Assume Your login page is index.asp
    inside page is 1.asp
    logout page is logout.asp

    1.index.asp
    Just store your username in session variable as Follows after user is authorized:
    Session("username") = username
    You need only one session variable here rather then two.

    2. 1.asp
    Use the Following code to authenticate the user:

    If Session("username")<>"" then
    'Authentication done.
    'go ahead with code of this page
    Else
    'Authentication Failed
    Response.Redirect "index.asp"
    End If

    3. Logout Page
    Session.Abandon
    Response.Redirect("index.asp")


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •