SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: Login ..

  1. #1
    SitePoint Enthusiast chillz88's Avatar
    Join Date
    Sep 2004
    Location
    S'pore
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Login ..

    I've already created a login page .. but how am i suppose to make sure that only those who login can access the member's areas and those who hasn't login will be redirected to login.asp ?? Is it possible to use cookies ???

  2. #2
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I use session variables for things like this. Once the user logs in, and is authenticated, create a session variable with their member ID in it. Then just check to make sure that session holds a value:

    Code:
    If session("memberID") = "" OR IsNull(session("memberID")) = True then
      response.redirect "login.asp"
    End if
    'display the member area code after this IF statement.

  3. #3
    SitePoint Enthusiast chillz88's Avatar
    Join Date
    Sep 2004
    Location
    S'pore
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    other than session ??? is there any other alternatives ??

  4. #4
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    client-side cookies.

    You could also send a user ID through each link with them making it sort of a database cookie, but this isn't recommended.

  5. #5
    SitePoint Enthusiast chillz88's Avatar
    Join Date
    Sep 2004
    Location
    S'pore
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if i want to use cookies .. will this work ??

    <%
    if Cookies("member_id") = "" then
    Response.Redirect("login.asp")
    else
    Response.write("Welcome " & Cookies("name"))
    end if
    %>

  6. #6
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No.

    You call a cookie like this:
    Code:
    If Request.Cookies("firstname") = "" then
    and create a cookie like this:
    Code:
    Response.Cookies("firstname")="Mongo"
    Here's a nice little tutorial on cookies:
    http://www.w3schools.com/asp/asp_cookies.asp

  7. #7
    SitePoint Enthusiast chillz88's Avatar
    Join Date
    Sep 2004
    Location
    S'pore
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    still lost ...

    i'm still lost i spend 2 hrs on it but to no avail ...

    The scenario ..

    User must login to access the webpages ..
    User can log out later ..
    If user have not log in, it will revert back to the login page ..

    My problem is ..

    I use the code below
    <%
    If Request.Cookies("mem_id") = "" then
    Response.Redirect "Login.asp"
    Response.End
    end if
    %>


    From Login.asp, user who have log in will go to Login_Success.asp. At Login_Success.asp, there's a link for user to enter Home.asp (Member's area).
    But when i click the link, it revert back to login.asp!

    My question..
    How to make the user stay log in when browsing the home.asp as well as other links in home.asp. User should be able to logout from the logout link found in all the pages.

    PLEASE HELP ME ... I've been doing this for over a week already ... I'm not good at asp ...

  8. #8
    SitePoint Enthusiast chillz88's Avatar
    Join Date
    Sep 2004
    Location
    S'pore
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone ??

  9. #9
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dont see why you dont want to use session variables, it simplifies the process for you.

    If you choose to use cookies, it would mean that whenever the user logs out, the cookie would be delete or you would have to write new values to the cookie.

    Personally, i havent heard of any other way to track users except session variables. Unless you want to travell a thousand miles via horse back, when u have cheaper, alternative faster means

  10. #10
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cookies would be good if you want to track a users "SESSION" or visit to your site, if he is logged in or not.

    Secondly, if he is logged in, you could track he/her visit to your site, as they navigate thru the pages of multiple open browsers.

    If you still want an alternative means, you could insert a value into a database or text file with the log in date and use that to track them, but it would mean opening and closing of your backend resources as the user navigates through

    ???

  11. #11
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should use Session variables. On the login process page assign the user id to the Session valriable

    Session("Id") = ID

    and then take the user to the member.asp page. When user clicks on logout link, take the user to logout page, make Session("Id") = '' and then display logout message or take the user to some generic page.

    On your restricted pages check at the top of the page if session is not blank. Also bring the user back to the page from where you are taking the user to the login page. You can accomplish this by passing a link string to the login page, from there pass it to login process page. If this string is empty then take the user to what ever page you want to, otherwise take the user to this string link.

    here is the example:

    Lets assume your login page is in the folder Auth which is in the root
    and your user is accessing the myinfo.asp page which is in the members folder which is in the root

    on myinfo.asp page put the following code
    if SessionI("Id") = '' then
    Response.Redirect("/Auth/login.asp?bringback=/members/myinfo.asp")
    end if


    on the login.asp page get the bringback parameter from the query string

    dim bringback = Request.QueryString("bringback")

    pass this to login process page and then get it on the page as above. After successfull login check

    if bringback <> '' then
    Response.Redirect(bringback)
    else
    Response.Redirect("genericpage.htm")
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...


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
  •