.NET Forum / ASP.NET / General / August 2007
Cookie problem
|
|
Thread rating:  |
Bill Nicholson - 02 Aug 2007 04:31 GMT Maybe I don't understand cookies correctly. When some visits my site and logs in, they get a cookie that stores their login information. When they come back, that info is read from the cookie and they can log in without having to remember their id/pw.
Assume the site is www.foobar.com It works as long as they browse to www.foobar.com. If they browse to foobar.com it doesn't see the cookie. It they browse to www.foobar.com/Stuff.aspx, it doesn't see the cookie.
What am I missing? Do I need to store the cookie differently?
Response.Cookies("CookieName").Value = tmpObject.Text.Trim Response.Cookies("CookieName").Expires = DateTime.Now.AddDays(1000)
The cookie looks fine - I checked it through the browsers (IE 6 and FireFox).
Thanks,
Bill Cincinnati, OH USA
Alexey Smirnov - 02 Aug 2007 09:34 GMT On Aug 2, 5:31 am, Bill Nicholson <namewitheldbyrequ...@gmail.com> wrote:
> Maybe I don't understand cookies correctly. When some visits my site > and logs in, they get a cookie that stores their login information. [quoted text clipped - 19 lines] > Bill > Cincinnati, OH USA Hi Bill,
add Trace="true" to the @Page directive at the start of the page, then you should see details of your cookies
<%@ Page Trace="true" ... %>
Hope this helps to find the problem
Laurent Bugnion, MVP - 02 Aug 2007 09:53 GMT Hi,
> Maybe I don't understand cookies correctly. When some visits my site > and logs in, they get a cookie that stores their login information. [quoted text clipped - 5 lines] > cookie. It they browse to www.foobar.com/Stuff.aspx, it doesn't see > the cookie. Make sure you set the Cookie's path correctly. If you want the cookie to be visible on your whole site, you must set the path to "/". http://msdn2.microsoft.com/en-us/library/system.net.cookie.path.aspx
HTH, Laurent
 Signature Laurent Bugnion [MVP ASP.NET] Software engineering, Blog: http://www.galasoft.ch PhotoAlbum: http://www.galasoft.ch/pictures Support children in Calcutta: http://www.calcutta-espoir.ch
Eliyahu Goldin - 02 Aug 2007 10:03 GMT Well, there can be a problem if the path is set in anything different from "/", There shouldn't be a problem if the path is not set at all. At the msdn states:
If this property is not specified, then this Cookie will be sent to all pages on the origin server or servers.
 Signature Eliyahu Goldin, Software Developer Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
> Hi, > [quoted text clipped - 14 lines] > HTH, > Laurent Laurent Bugnion, MVP - 02 Aug 2007 12:55 GMT Hi,
> Well, there can be a problem if the path is set in anything different from > "/", There shouldn't be a problem if the path is not set at all. At the msdn > states: > > If this property is not specified, then this Cookie will be sent to all > pages on the origin server or servers. That would mean that the default value is "/". Anyway, the symptom being that the cookie is not visible on all pages, this rather points to a problem with the Path.
Greetings, Laurent
 Signature Laurent Bugnion [MVP ASP.NET] Software engineering, Blog: http://www.galasoft.ch PhotoAlbum: http://www.galasoft.ch/pictures Support children in Calcutta: http://www.calcutta-espoir.ch
Bill Nicholson - 02 Aug 2007 16:01 GMT If the path is not specified, then it defaults to '/'. And I am not specifying it. So what's the problem?
On Aug 2, 7:55 am, "Laurent Bugnion, MVP" <galasoft...@bluewin.ch> wrote:
> Hi, > [quoted text clipped - 16 lines] > PhotoAlbum:http://www.galasoft.ch/pictures > Support children in Calcutta:http://www.calcutta-espoir.ch Laurent Bugnion, MVP - 02 Aug 2007 17:23 GMT Hi,
> If the path is not specified, then it defaults to '/'. And I am not > specifying it. So what's the problem? No problems on my side. You described a symptom, I described the most common cause for it. We've got to start somewhere.
On the client side, when you watched document.cookie, what does the cookie string look like, and is the "path" part set?
HTH, Laurent
 Signature Laurent Bugnion [MVP ASP.NET] Software engineering, Blog: http://www.galasoft.ch PhotoAlbum: http://www.galasoft.ch/pictures Support children in Calcutta: http://www.calcutta-espoir.ch
Bill Nicholson - 02 Aug 2007 19:00 GMT Sorry, Laurent. I meant "What's the problem with my cookie". I wasn't flaming you. My bad!
On Aug 2, 12:23 pm, "Laurent Bugnion, MVP" <galasoft...@bluewin.ch> wrote:
> Hi, > [quoted text clipped - 14 lines] > PhotoAlbum:http://www.galasoft.ch/pictures > Support children in Calcutta:http://www.calcutta-espoir.ch Laurent Bugnion, MVP - 02 Aug 2007 19:12 GMT Hi,
> Sorry, Laurent. I meant "What's the problem with my cookie". I wasn't > flaming you. My bad! No worries Bill. I also wonder what's wrong with your cookie. YOu said you checked the cookie in IE and Netscape, you mean you watched the "document.cookie" JavaScript variable? Or what method did you use?
If you can, post the "document.cookie" string which is stored in the client. You can do that using JavaScript in your web page. It would be helpful to see what is really sent to the client, not just the high-level API calls in ASP.NET.
HTH, Laurent
 Signature Laurent Bugnion [MVP ASP.NET] Software engineering, Blog: http://www.galasoft.ch PhotoAlbum: http://www.galasoft.ch/pictures Support children in Calcutta: http://www.calcutta-espoir.ch
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|