Link to home
Start Free TrialLog in
Avatar of g-spot
g-spot

asked on

Redirect on first visit only - classic asp

I know a fair deal about ASP.net but I'm not so great with classic ASP.

On a classic ASP site I need to forward the user on the **first** visit of the session to another page that displays some information. This information page is written in ASP.net and once the user has seen this information they may then carry on with browsing the classic ASP site as usual.

I'm not sure how to force the direct in classic ASP just one time only.

If I put a response.redirect in the classic ASP home page to the ASP.net page, every time that page is viewed the user will be redirected. However I just want this redirection to happen once at the start of the session.

Can anyone help?
Avatar of Xenus99
Xenus99

You can do it with cookies, If the cookie shows that is the first time visit do the response.redirect, otherwise the user can continue browsing the site.
For the first visit/call per session you can use the following:
<%
If Session("FirstCall") = "" Then
  Response.Redirect "firstcall.asp"
  Session("FirstCall") = "false"
End If
%>

Open in new window

If you want to track the user and only redirect him on his very first visit to your site, you have to set a cookie and read this cookie:
<%
If Request.Cookie("FirstVisit") = "" Then
  Response.Redirect "firstcall.asp"
  Response.Cookie("FistVisit") = "false"
End If
%>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Sven
Sven
Flag of Germany 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
Remember that deactivating (session-)cookies will lead to a redirect on ever call! so you better give a hint to the user that he maybe have to allow cookies.