Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Cookie

Options
  • 01-04-2004 11:08am
    #1
    Registered Users Posts: 446 ✭✭


    I've made a login page with cookies that checks the username & password in a table...and goes on to check just the username to see if that person exsists if they enter wrong password

    Now I have that working fine, but now i have to add in a little extra cookie that takes whatever type they choose when they register this can be general, company, and I can change i t to admin.

    What needs to happen is when they login it checks the table to see what type of account they have and redirects them to the page for them e.g admin.asp, company.html etc.


    I've no idea where to start with this one...any ideas?

    Kate


Comments

  • Registered Users Posts: 1,023 ✭✭✭[CrimsonGhost]


    Generate a simple page with
    <html>
    <head>
    <META HTTP-EQUIV=Refresh CONTENT="1; URL=http://www.yoursite.com/admin.asp"&gt;
    </head>
    <body>Please wait your are being redirected</body>
    </html>

    or

    <html>
    <head>
    <META HTTP-EQUIV=Refresh CONTENT="1; URL=http://www.yoursite.com/company.html"&gt;
    </head>
    <body>Please wait your are being redirected</body>
    </html>

    And alternative would be to send a redirect header before sending any content and this will redirect them. This would probably be a better approach if you can do it. It's easy in php and perl dunno about asp though.


    This may not be the best approach though. If both logins have similar functionality you may want to send them to the same page, and just generate extra "admin" menu stuff if they are admins. That way you aren't double up on code across pages.
    And also if you add an extra freature that is available to everyone at a later date you only add it in one place. Hope that makes sense.


  • Registered Users Posts: 2,158 ✭✭✭Serbian


    If you are using ASP, a simple script like so would work:
    <% Option Explicit %>
    <%
    Dim sUsername, sSQL, sUsertype
    
    sUsername = Response.GetCookie("username")
    
    sSQL = "SELECT UserType FROM table WHERE Username = '" & sUsername & "'"
    
    ' Do whatever DB stuff here
    
    sUsertype = MyRS("UserType")
    
    If sUsertype = "admin" then
       Response.Redirect("admin.asp")
    ElseIf sUsertype = "company" then
       Response.Redirect("company.asp")
    Else
       Response.Redirect("RegularJoe.asp")
    End If
    %>
    


Advertisement