Solved

First Visit code

Posted on 2009-05-09
4
302 Views
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

0
Comment
Question by:lrbrister
  • 2
4 Comments
 
LVL 17

Expert Comment

by:OriNetworks
ID: 24344565
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.
http://www.w3schools.com/asp/ev_sess_onend_onstart.asp

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.
0
 
LVL 20

Expert Comment

by:informaniac
ID: 24344939
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.
0
 
LVL 9

Expert Comment

by:tillgeffken
ID: 24345003

        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

0
 
LVL 9

Accepted Solution

by:
tillgeffken earned 500 total points
ID: 24345017
Forgot a little something in my code there.


If (IsNewVisit()) Then
  'Show Movie
Else
  'Show Random Image
End If
   

        Public Function IsNewVisit() As Bool

                If (HttpContext.Current.Session("Visited") Is Nothing) Then

                    HttpContext.Current.Session("Visited") = 1

                    Return True

                End If

                Return False

        End Function

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now