Results 1 to 9 of 9

Thread: Getting cookies data

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Getting cookies data

    I have an application where I use the standard login controls from VS 2005.

    I have a problem, how do I get the user info if the user has marked the checkbox "remember me"?
    In my application I load the username, when the user is logging in, that is the textbox named Login1.LayoutTemplate.UserName

    How do I get the data when the user automatically is logged in and doesn't enter the user name?

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Getting cookies data

    Hey,

    You should be able to use:

    Code:
    HttpContext.Current.User.Identity.Name
    I haven't got Visual Studio open in front of me just now, but you should be able to shorten the above to:

    Code:
    User.Identity.Name
    If I remember correctly, but you would need to check.

    Gary

  3. #3
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Thumbs down Re: Getting cookies data

    Quote Originally Posted by gep13 View Post
    Hey,

    Code:
    HttpContext.Current.User.Identity.Name
    I haven't got Visual Studio open in front of me just now, but you should be able to shorten the above to:

    Code:
    User.Identity.Name

    Gary
    i've checked that...

    Remember Me option Doesn't Remember Me....

    even if i use

    Code:
    FormsAuthentication.RedirectFromLoginPage(UserName.Text,true);
    i mean once u close the browser...

    you are logged out...!

    so any help on this..?

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Getting cookies data

    Hey,

    I was referring to the use of the ASP.Net Membership Provider, not a self implemented "Remember Me", is this what you are referring to?

    Gary

  5. #5
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Re: Getting cookies data

    Yes i mean
    Code:
    if(Membership.ValidateUser(UserName,Passoword))
      FormsAuthentication.RedirectFromLoginPage(UserName.Text,true);
    also instead of this if i write my own custom logic then..it would be
    Code:
    if(UserName == DatabaseUserName && Password == DataBasePassword)
    {
       FormsAuthentication.RedirectFromLoginPage(UserName.Text,true);
    }
    In bothe case Remember Me i've Kept true.
    so the persistent cookie will be created but...
    it does not Remember...!

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Getting cookies data

    Hey,

    Which browser are you testing this with? Are cookies enabled?

    Gary

  7. #7
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Re: Getting cookies data

    yup...cookies heavily enabled

    now u tell me...according to you wot should happen..?

    am i missing any procedure...?

    or you u tell me hw should i proceed..!

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Getting cookies data

    Hey,

    First of all, I would be checking your cookies to make sure that a cookie has been created. If required, I would call the other overload for the RedirectFromLoginPage to include a path to the cookie:

    http://msdn.microsoft.com/en-us/library/1f5z1yty.aspx

    From there, I would ask, how are you verifying that the "Remember Me" functionality isn't working?

    Gary

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Re: Getting cookies data

    You can try to validate the user using
    Dim usern As MembershipUser = Membership.GetUser()

    I think the problem is can be caused by the session timeout, please try to set your session timeout to 100000 in your webconfig just for testing this

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