Web Hosting Talk







View Full Version : How to make a simple cookie in ASP?


Kristine
10-12-2005, 09:48 PM
I have this little flash movie on the main page of a website and I want to set the cookie so that when user first enters the site, the flash plays but when the user browses around and goes back to the main page, the flash movie won't repeat again ... kinda like ........ they can only see the movie 1 time when first entering the site but after that they won't be able to see it again unless they clear their cookies from their computer.

I'm not really a programmer and I really don't know much about these...

i'm totally clueless

hafa
10-13-2005, 11:04 AM
Put this where you want your flash movie:

<%If Request.Cookies("flashmovie") <> "Yes" Then%>

!--Put your flash movie code here-->

<%End If%>

Put this at the end of the page:

<%

' declare variables for the cookie
Dim strCookieName
Dim strCookieValue

' set the cookie variables for this page
strCookieName = "flashmovie"
strCookieValue = "Yes"

Response.Cookies(strCookieName) = strCookieValue
Response.Cookies(strCookieName).Expires = Date() + 365
%>

The Date()+365 makes the cookie valid for one year; you can enter any value you wish...