We help IT Professionals succeed at work.

First Visit code

Larry Brister
Last Modified: 2013-11-26
In my code behind you see attached I have a random image loaded.

What I WANT to do is to load a movie the FIRST time they visit and then after 10 seconds load the Random code below.

If they revisit the page during same session, they won't see the movie.
Dim rand As New Random()
        Me.imgLogin.ImageUrl = String.Format("images/random/{0}.jpg", rand.Next(1, 5))
        Session("visit") = "true"

Open in new window

Watch Question


I would use a session variable and edit the global.asa file to detect when the user visits the site using the Session_OnStart event.

So when someone visits the site for the first time, the session_onstart event runs and sets Session("FirstVisit")="true"

Then on that page that you run the video, you can use and if statement to see if firstvisit is still true and if so run the video and set Session("FirstVisit")=false else dont do anything because that means the video was already run.
Obadiah ChristopherDeveloper User Interface

You could probably use a cookie and store the user id in the cookie.

So the next time the user logins, you could check whether the cookie exists or not. If it exists then don't load the movie.

        Public Function IsNewVisit() As Bool
                If (HttpContext.Current.Session("Visited") Is Nothing) Then
                    HttpContext.Current.Session("Visited") = 1
                    Return True
                End If
        End Function

Open in new window

This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.