Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

First Visit code

Posted on 2009-05-09
4
Medium Priority
?
309 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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

926 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