accesing a cookie from two different web applications
-
hey, i wrote some code in Application1 that encrypts a string and saves it in a cookie, and i want to retrieve that string from the cookie i saved from Application 2. My question is: how can i access the same cookie from two different web applications? Thanks
-
hey, i wrote some code in Application1 that encrypts a string and saves it in a cookie, and i want to retrieve that string from the cookie i saved from Application 2. My question is: how can i access the same cookie from two different web applications? Thanks
-
You can only do that if the applications use the same domain name. Cookies are private to the domain, for security reasons. --- b { font-weight: normal; }
-
first of all , thanks guffa. In fact, i set the domain "localhost" in the cookie but it seems not to work
-
this way: HttpCookie simpleCookie = new HttpCookie( "testCookie" ); simpleCookie.Domain = "localhost"; simpleCookie.Path = "/";
From MSDN: "Setting the Domain attribute limits transmission of the cookie to clients requesting a resource from that domain." This means that the cookie will only be sent to the browser if it requests a page from the domain specified. You cannot use the domain property to inject a cookie into a different domain. --- b { font-weight: normal; }
-
From MSDN: "Setting the Domain attribute limits transmission of the cookie to clients requesting a resource from that domain." This means that the cookie will only be sent to the browser if it requests a page from the domain specified. You cannot use the domain property to inject a cookie into a different domain. --- b { font-weight: normal; }
So you are trying to use the same cookie on the same server that has 2 different virtual directories setup? If so then you can do the quick and dirty and post all cookie values (from Virutal Directory 1) in a form (Html Hidden input) to the a seperate CookieMigration page (in Virutal Directory 2). The CookieMigration page would simply loop through all of the form values and then place them into a new cookie.
-
So you are trying to use the same cookie on the same server that has 2 different virtual directories setup? If so then you can do the quick and dirty and post all cookie values (from Virutal Directory 1) in a form (Html Hidden input) to the a seperate CookieMigration page (in Virutal Directory 2). The CookieMigration page would simply loop through all of the form values and then place them into a new cookie.