logoff button that delete a cookie

Discussion in 'C#' started by wak0, Dec 10, 2009.

  1. #1
    I have website that is authenticated using Active directory (no form authentication-simple password protected folder that prompts for credentials).

    Once the user enter his/her credentials, they have access to the password protected section. I need to have a logoff button that once the user click on it, the cookie that stores their credentials, gets modified or deleted, so if the user goes back to the link, the credentials are asked again. All this without closing the browser.
     
    wak0, Dec 10, 2009 IP
  2. SEOLurker

    SEOLurker Peon

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <%
    Response.Buffer = True

    Dim strCookieName
    Dim strCookieValue

    strCookieName = CStr(Request.QueryString("name"))
    strCookieValue = CStr(Request.QueryString("value"))

    If strCookieName <> "" Then

    If strCookieValue <> "" Then
    Response.Cookies(strCookieName) = strCookieValue
    Response.Cookies(strCookieName).Expires = Date() + 1
    Else
    Response.Cookies(strCookieName) = "must be something!"
    Response.Cookies(strCookieName).Expires = Date() - 1
    End If
    End If

    Response.Redirect("yourpage.asp")
    %>
     
    SEOLurker, Dec 10, 2009 IP
  3. wak0

    wak0 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    on the code you sent

    do i need to change anything like the name of the cookie somewhere? other than the yourpage.asp

    let me show you how my file looks like

    <%
    Response.Buffer = True

    Dim strCookieName
    Dim strCookieValue

    strCookieName = CStr(Request.QueryString("name"))
    strCookieValue = CStr(Request.QueryString("value"))

    If strCookieName <> "" Then

    If strCookieValue <> "" Then
    Response.Cookies(strCookieName) = strCookieValue
    Response.Cookies(strCookieName).Expires = Date() + 1
    Else
    Response.Cookies(strCookieName) = "must be something!"
    Response.Cookies(strCookieName).Expires = Date() - 1
    End If
    End If

    Response.Redirect("index.html")
    %>
    <script>
    window.setTimeout("window.close()", 100);
    </script>


    is there anything else i need to change??????????????
     
    wak0, Dec 11, 2009 IP
  4. wak0

    wak0 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I dont know if this is normal behavior, but i check on firefox to show the cookies. and the cookie yesterday was named this

    ASPSESSIONIDCSTBCBSR

    today

    is name this

    ASPSESSIONIDASTBDBTR


    i tried that code, but it does not do what i need. it keeps loging me withouth asking me for credentials
     
    wak0, Dec 11, 2009 IP
  5. Jayr1021

    Jayr1021 Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Paste an example of what you are writing when someone logs in.
     
    Jayr1021, Dec 28, 2009 IP
  6. wak0

    wak0 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    would it be possible for someone to paste the content of logon.aspx and defautl.aspx of a form authentication that is working. I am very new at this and dont know how to code on vb. if you have a system that works comparing to active directory that will be helpfull. I have used several code and i am guessing none of them work because i dont know what i a m doing. so if you have baby steps to follow i will appreaciate it. is just the form that i need to compare to my active directory, i think they should have the same functionality right?
     
    wak0, Dec 29, 2009 IP