Solved

First Visit code

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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

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.…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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