romanlv
romanlv

Reputation: 1458

How to get name of authentication cookie for current session in Classic ASP

Classic ASP creates cookies with name something like ASPSESSIONIDSSDSQQCR where suffix after "ASPSESSIONID" is different. If you work for some time with application browser keeps storing all previous session cookies (could be 10 cookies or more), so there is no way to understand which cookie is for the current session

I know there is a way to get current SessionID

Session.SessionID

but how can I get a cookie value as well?


I'm just trying to create authentication solution for ASP.NET which is just addon for Main Classic ASP application.
In that design main application creates record in database with current Classic ASP cookie value and after that when user tries to access ASP.NET part, it just takes all "ASPSESSIONIDSSD+XXXXX" cookies in request and verifies which one of them is still valid by looking for initial record in database. If valid session found then it should initiate ASP.NET session....

Upvotes: 3

Views: 2342

Answers (1)

josh3736
josh3736

Reputation: 145162

I don't think you can get Classic ASP's Session ID cookie from ASP.NET. The Classic ASP session cookie has crypto applied to prevent your clients from tinkering with it. Unfortunately, this also prevents your .NET code from tinkering with the session cookie.

The easiest thing I can think of is to set an additional cookie in your Classic ASP code. Rather than storing the Classic Session ID in your database, store some other key, like a GUID. Then send a session cookie to the browser with the key.

Response.Cookies("SessionKey") = GeneratedGuid

You can then read the SessionKey cookie in .NET and lookup its value from the database.

Upvotes: 2

Related Questions