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_i d") = member_id in asp page
and in aspx page
Response.write(request.coo kies("memb er_id"))
but im not getting any values written
can anyone help me with this
Thanx in adavance
like i used
response.Cookies("member_i
and in aspx page
Response.write(request.coo
but im not getting any values written
can anyone help me with this
Thanx in adavance
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_I D").path = "/mypath"
response.Cookies("Member_I
ASKER
thanx for ur help..but i got it worked in another way
In asp
response.Cookies("memberid ") = member_id
In aspx
Response.Write(Request.Coo kies("memb erid").Val ue())
the '_' in meber_id was giving me error!!! "object not set to an instance of an object!" dono why..but working now :)
In asp
response.Cookies("memberid
In aspx
Response.Write(Request.Coo
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("CookieNa me").Path = /VirtualPathThe following sets the cookie's path.
Response.Cookies("User").P ath = "/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 :)
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("CookieNa
Response.Cookies("User").P
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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