Can't Write Cookie IE

Discussion in 'ASP .Net' started by =?Utf-8?B?R2FycmV0dEQ3OA==?=, Jul 5, 2005.

  1. I am having trouble with my authentication cookie with IE. I create and write
    the cookie here but some of the client PC never get the cookie. This does
    work with other browsers like Firefox.

    If Request.Cookies("portalroles") Is Nothing Then

    Dim _user As New UsersDB
    Dim roleStr As String = ""
    Dim role As String

    roleStr = _user.GetRoles(User.Identity.Name)


    'For Each role In roles

    'roleStr += role
    'roleStr += ";"

    'Next

    Dim ticket As New FormsAuthenticationTicket(1, _
    Context.User.Identity.Name, _
    DateTime.Now, _
    DateTime.Now.AddHours(1), _
    False, _
    roleStr)

    Dim cookieStr As String = FormsAuthentication.Encrypt(ticket)


    'Send Cookie to client
    Response.Cookies("portalroles").Value = cookieStr
    Response.Cookies("portalroles").Path = "/"
    Response.Cookies("portalroles").Expires =
    DateTime.Now.AddMinutes(5)

    Worst part is this works on most of my clients but not on other.s
    Thanks
    =?Utf-8?B?R2FycmV0dEQ3OA==?=, Jul 5, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?R2FycmV0dEQ3OA==?=

    Curt_C [MVP] Guest

    Are you sure the clients have their browser set to allow cookies?
    Some dont.


    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com


    GarrettD78 wrote:
    > I am having trouble with my authentication cookie with IE. I create and write
    > the cookie here but some of the client PC never get the cookie. This does
    > work with other browsers like Firefox.
    >
    > If Request.Cookies("portalroles") Is Nothing Then
    >
    > Dim _user As New UsersDB
    > Dim roleStr As String = ""
    > Dim role As String
    >
    > roleStr = _user.GetRoles(User.Identity.Name)
    >
    >
    > 'For Each role In roles
    >
    > 'roleStr += role
    > 'roleStr += ";"
    >
    > 'Next
    >
    > Dim ticket As New FormsAuthenticationTicket(1, _
    > Context.User.Identity.Name, _
    > DateTime.Now, _
    > DateTime.Now.AddHours(1), _
    > False, _
    > roleStr)
    >
    > Dim cookieStr As String = FormsAuthentication.Encrypt(ticket)
    >
    >
    > 'Send Cookie to client
    > Response.Cookies("portalroles").Value = cookieStr
    > Response.Cookies("portalroles").Path = "/"
    > Response.Cookies("portalroles").Expires =
    > DateTime.Now.AddMinutes(5)
    >
    > Worst part is this works on most of my clients but not on other.s
    > Thanks
    Curt_C [MVP], Jul 5, 2005
    #2
    1. Advertising

  3. Sorry I forgot to mention that. Yes we have worked and worked with the
    clients including setting their privacy settings to nothing and this stil
    doesn't seem to have any effect.

    "Curt_C [MVP]" wrote:

    > Are you sure the clients have their browser set to allow cookies?
    > Some dont.
    >
    >
    > --
    > Curt Christianson
    > site: http://www.darkfalz.com
    > blog: http://blog.darkfalz.com
    >
    >
    > GarrettD78 wrote:
    > > I am having trouble with my authentication cookie with IE. I create and write
    > > the cookie here but some of the client PC never get the cookie. This does
    > > work with other browsers like Firefox.
    > >
    > > If Request.Cookies("portalroles") Is Nothing Then
    > >
    > > Dim _user As New UsersDB
    > > Dim roleStr As String = ""
    > > Dim role As String
    > >
    > > roleStr = _user.GetRoles(User.Identity.Name)
    > >
    > >
    > > 'For Each role In roles
    > >
    > > 'roleStr += role
    > > 'roleStr += ";"
    > >
    > > 'Next
    > >
    > > Dim ticket As New FormsAuthenticationTicket(1, _
    > > Context.User.Identity.Name, _
    > > DateTime.Now, _
    > > DateTime.Now.AddHours(1), _
    > > False, _
    > > roleStr)
    > >
    > > Dim cookieStr As String = FormsAuthentication.Encrypt(ticket)
    > >
    > >
    > > 'Send Cookie to client
    > > Response.Cookies("portalroles").Value = cookieStr
    > > Response.Cookies("portalroles").Path = "/"
    > > Response.Cookies("portalroles").Expires =
    > > DateTime.Now.AddMinutes(5)
    > >
    > > Worst part is this works on most of my clients but not on other.s
    > > Thanks

    >
    =?Utf-8?B?R2FycmV0dEQ3OA==?=, Jul 5, 2005
    #3
  4. =?Utf-8?B?R2FycmV0dEQ3OA==?=

    Curt_C [MVP] Guest

    GarrettD78 wrote:
    > Sorry I forgot to mention that. Yes we have worked and worked with the
    > clients including setting their privacy settings to nothing and this stil
    > doesn't seem to have any effect.
    >


    Ok... guess the next thing is to find out what IS different.
    If one client works and the next doesnt and they both have the same
    browser start looking deeper. Most likely its not a server issue, its a
    client one. Firewalls, proxy servers, etc... also, OS ver, Service
    Packs, etc....

    Sorry I cant be more specific in this instance but its a difficult one
    to know. There are a number of options

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com
    Curt_C [MVP], Jul 5, 2005
    #4
  5. Well thanks. I have been trying to figure out what is different but haven't
    had any luck. Just seems strange because you can surf other sites and the
    cookies write and can be read fine but my site it won't work.

    "Curt_C [MVP]" wrote:

    > GarrettD78 wrote:
    > > Sorry I forgot to mention that. Yes we have worked and worked with the
    > > clients including setting their privacy settings to nothing and this stil
    > > doesn't seem to have any effect.
    > >

    >
    > Ok... guess the next thing is to find out what IS different.
    > If one client works and the next doesnt and they both have the same
    > browser start looking deeper. Most likely its not a server issue, its a
    > client one. Firewalls, proxy servers, etc... also, OS ver, Service
    > Packs, etc....
    >
    > Sorry I cant be more specific in this instance but its a difficult one
    > to know. There are a number of options
    >
    > --
    > Curt Christianson
    > site: http://www.darkfalz.com
    > blog: http://blog.darkfalz.com
    >
    =?Utf-8?B?R2FycmV0dEQ3OA==?=, Jul 5, 2005
    #5
  6. =?Utf-8?B?R2FycmV0dEQ3OA==?=

    Curt_C [MVP] Guest

    GarrettD78 wrote:
    > Well thanks. I have been trying to figure out what is different but haven't
    > had any luck. Just seems strange because you can surf other sites and the
    > cookies write and can be read fine but my site it won't work.
    >

    I've had similar in the past and most of the time it ended up being the
    security settings in IE actually, specifically the URL getting read as
    intranet inadvertantly (or vice versa).

    As a test just do a simple 2 page app with one writing and one reading
    and put it out on your server and start with that as a control group, to
    eliminate something with your specific site setup... just to see.


    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com
    Curt_C [MVP], Jul 6, 2005
    #6
    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.

Share This Page