Results 1 to 5 of 5

Thread: how would I know if a user is logged on?

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    how would I know if a user is logged on?

    I'm usign forms authentication. I have a login page which uses this line to set a cookie and redirect:

    FormsAuthentication.RedirectFromLoginPage(username, False)

    I have a single page in my project that is public to every user, whether they are logged in or not. I'm wondering how I can determine if the user that's viewing that public page is logged in or not.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    sorry if i am saying BS but maybe by reading the cookies? if the cookie is not null then he is logged, otherwise he is not
    \m/\m/

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by PT Exorcist
    sorry if i am saying BS but maybe by reading the cookies? if the cookie is not null then he is logged, otherwise he is not
    naah you're not saying bs! hehe

    Umm I thought of that... but the cookie isnt null even if the user has logged out (I dont know anything about how this cookie business works anyways )

    anyone can tell me how though? I thought it's really easy
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Once the user is authenticated, you can access there user name from Context.User.Identity.Name from any code behind page.

    So you can check like this
    Code:
    if(Context.User.Identity.IsAuthenticated)
    {
         Response.Write("User logged in");
    }

  5. #5

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by DevGrp
    Once the user is authenticated, you can access there user name from Context.User.Identity.Name from any code behind page.

    So you can check like this
    Code:
    if(Context.User.Identity.IsAuthenticated)
    {
         Response.Write("User logged in");
    }
    yay it's workin! thanks
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

Posting Permissions

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



Click Here to Expand Forum to Full Width