Solved

First Visit code

Posted on 2009-05-09
4
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 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