Link to home
Start Free TrialLog in
Avatar of tonykmathew
tonykmathew

asked on

Share Cookie value between asp and aspx pages

I have an application which has both asp and aspx pages. in one of my asp page say login page am storing the loginid in cookie. i am not able to read or write this cookie value from my aspx page
like i used
response.Cookies("member_id") = member_id in asp page

and in aspx page

Response.write(request.cookies("member_id"))
but im not getting any values written

can anyone help me with this

Thanx in adavance
Avatar of rdrunner
rdrunner

You need to set the response.Cookies("Member_ID").path property so its below the asp and aspx page...

If you dont set this property it will default to the ASP path and if the aspx path is in another folder it wont be able to see it



Hope this helps
Avatar of tonykmathew

ASKER

I dint get u clearly...where shall i set the path???...any smaple code?
You need to set the path like this...


response.Cookies("Member_ID").path = "/mypath"
thanx for ur help..but i got it worked in another way

In asp
response.Cookies("memberid") = member_id

In aspx
Response.Write(Request.Cookies("memberid").Value())

the '_'  in meber_id was giving me error!!! "object not set to an instance of an object!" dono why..but working now :)
Setting a Virtual Path for the Cookie
The Path property sets the path that this cookie pertains to. The cookie will only be retrieved from the client if pages are retrieved from the directory set by Path.

The syntax for setting the Path property of a cookie is:

    Response.Cookies("CookieName").Path = /VirtualPathThe following sets the cookie's path.

    Response.Cookies("User").Path = "/customers"

If the Path property is not specified it will be set to the directory where the cookie was created. Setting a Path of root, "/", causes the cookie to be sent to the server throughout the site.

Here is the long version :)
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial