Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookie Question ASP.net and Classic ASP

Status
Not open for further replies.

fmrock

Programmer
Joined
Sep 5, 2006
Messages
510
Location
US
I have been tasked with updating some code in a DNN portal that one of our old programmers added. This is an ASP.net application.

Here is the cookie logic that they have added.

Code:
Dim ABCCookie As New HttpCookie("EmployeeNumber", _empNo)
ABCCookie.Expires = DateTime.Now.AddMinutes(10)
Response.Cookies.Add(ABCCookie)

Dim ABCCookie2 As New HttpCookie("UserID", _username)
ABCCookie2.Expires = DateTime.Now.AddMinutes(10)
Response.Cookies.Add(ABCCookie2)

This is in the page_init sub and seems to work for most users.. but we are having an issue with some.

The problem arises when the user clicks a link to a classic ASP page that needs to read these cookies.

My question to you all is....

1. Is there anything more that needs to be done to the cookies to make them readable by classic ASP?

2. Does the cookie expire in 10 minutes or 10 minutes of inactivity.

Here is the code that is in the classic ASP page that reads the cookie and does the redirect.

Code:
dim cookieVal : cookieVal =Request.Cookies("EmployeeNumber")

response.Redirect("[URL unfurl="true"]https://www.domain.com/login.asp?id="[/URL] & cookieVal)

Response.Write (cookieVal)


What is strange is this works for some users, but others it does not. It has nothing to do with there login criteria to our system as we cant replicate this on any of our test systems or test environments.

Thanks for any help or insite you may have.
 
ca8msm,

Would it be a better idea/easier to use a simple .aspx page to read the cookie and do the redirect?
 
If the aspx page was part of the same site then yes, as the cookie would be able to be read as part of the session. Interacting between websites using different technologies is always going to be the harder of the options so if you have the option to avoid it (which isn't always possible) then it's probably better to take that option.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
The classic asp page and the .net solution are on the same server/domain. I need to be able to read that cookie and redirect.

Does the cookie logic from the .net look correct? There are some comments in the odl programmers code to add the domain to the cookie so it can be read by classic ASP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top