login

Discussion in 'ASP General' started by bender, Sep 16, 2003.

  1. bender

    bender Guest

    Im in the process of making a login script. I was thinking of doing
    something like
    session("User") = rs("Username")

    but how do I check if a user is already logged in or not ? I mean, if the
    user isnt' logged in then the session variable isnt created and I would get
    an variable error of some kind. Just looking for some input.

    Cheers :)
    bender, Sep 16, 2003
    #1
    1. Advertising

  2. bender

    Khanh Pham Guest

    check the form text field name and compare it to the session. if it matches
    then the user already logged in. use something like:

    if request.form("userid") = Session("userid") then
    'already logged in
    else
    'continue processing checking against database
    end if

    hope this helps
    "bender online.no>" <laasunde@<> wrote in message
    news:%...
    > Im in the process of making a login script. I was thinking of doing
    > something like
    > session("User") = rs("Username")
    >
    > but how do I check if a user is already logged in or not ? I mean, if the
    > user isnt' logged in then the session variable isnt created and I would

    get
    > an variable error of some kind. Just looking for some input.
    >
    > Cheers :)
    >
    >
    >
    >
    Khanh Pham, Sep 16, 2003
    #2
    1. Advertising

  3. bender

    Dan Brussee Guest

    On Tue, 16 Sep 2003 12:51:54 +0200, "bender" <laasunde@<>online.no>
    wrote:

    >Im in the process of making a login script. I was thinking of doing
    >something like
    >session("User") = rs("Username")
    >
    >but how do I check if a user is already logged in or not ? I mean, if the
    >user isnt' logged in then the session variable isnt created and I would get
    >an variable error of some kind. Just looking for some input.


    The session "OBJECT" is always there. It is a collection of items...
    one of which may be named "User". If that item does not exist when you
    test it's value, then a blank string will be returned...

    if session("User") = "" then ' Nobody has logged in yet
    Dan Brussee, Sep 16, 2003
    #3
  4. bender

    PB4FUN Guest

    I mostly use an include file that does a check like this :

    If Session("User") = "" then
    response.redirect "login.asp"

    else
    'Do nothing
    end if

    In the login.asp you do a Select count(username) From ...... query
    where you check for the Request("Username") and the Request("password")

    After getting the RS do this :

    If Rs.fields(0).Value > 0 then
    Session("User") = strLoginName 'from the Request("Username")
    else
    Response.write "User not found or wrong password."
    end if

    Meindert, MCP

    > Im in the process of making a login script. I was thinking of doing
    > something like
    > session("User") = rs("Username")
    >
    > but how do I check if a user is already logged in or not ? I mean, if the
    > user isnt' logged in then the session variable isnt created and I would

    get
    > an variable error of some kind. Just looking for some input.
    >
    > Cheers :)
    >
    >
    >
    >
    PB4FUN, Sep 16, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William F. Robertson, Jr.
    Replies:
    0
    Views:
    439
    William F. Robertson, Jr.
    Jul 2, 2003
  2. Hermit Dave

    Forms Login Page Not Login Out

    Hermit Dave, Jan 12, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    475
    Hermit Dave
    Jan 13, 2004
  3. Nans
    Replies:
    2
    Views:
    20,096
    Martin Marinov
    Jun 17, 2004
  4. =?Utf-8?B?Z2FyaWJhbGRp?=
    Replies:
    2
    Views:
    4,923
    =?Utf-8?B?Z2FyaWJhbGRp?=
    Feb 25, 2005
  5. frekster
    Replies:
    1
    Views:
    931
    frekster
    Sep 14, 2005
Loading...

Share This Page