Cookie Sample
This is a Cookie sample that I stole (with permission) from a post written by Rob Keniger at the GoLive Talk List.
If you have previewed this page in a browser, you will have been prompted with a dialogue box.
You will see this message only once.
If you'd like to see it again, you have to delete the cookie in your browser's prefs.
Its called "MyCookie".
There might be some capitals first in the name set by the browser (DFT).
Click OK and try to reload the page, the message will not reappear.
The whole idea is to prompt the visitor who visits the site for the first time, with a dialogue box, stating some text message.
It could be a pop-up window or some other event - more on this later.
The prompt will happen once only.
Quoted from Rob Keniger's post:
"Basically what this does is check to see if the cookie is there, if not then it calls the Action group which writes the value "true" to the cookie and displays the alert. The next time you visit the page the alert will not display.
Also note that you must test this page when it is being served by a web server - it will *NOT* work when previewed from your local drive.
A final note - I helped Deb (Deborah Shadovitz) out a little with this stuff in the GoLive 5 Bible and there is a sample on the CD written by me demonstrating how to use the variable and cookie actions to do some funky stuff. I highly recommend getting a hold of this book because it explains how to use these actions very clearly (much more so than the manual).
You may also find the following Adobe URL useful:
http://www.adobe.com/support/techdocs/2149a.htm
(Above URL deals with GoLive 4.0, but it applies to all other GL versions as well. (Editors remark))
Hope this helps.
--
Rob Keniger"
When you have finished this set-up in the Head section (?). You will end up with five Head Actions like this.
If you open this page within GL and expand the head section, you will see the set up in live.
Start with this.
Apply five Head Actions (?) to the Head section.
The Steps
Apply the DeclareVariable.action (find it in the Variables folder) to Head Action #1.
Name the variable, in this case "WhatEver".
Set "Type" to "String".
Give the "Cookie" a name in this case "MyCookie".
Execute the Action by "OnLoad".
Apply the InitVariable.action (find it in the Variables folder) to Head Action #2.
Choose the variable you just created from the "Variable" popup.
In the "Value" field set the value of the variable to "false" (just type it in).
Execute the Action by "OnLoad".
Apply the ReadCookie.action (find it in the Variables folder) to Head Action #3.
In the "Name" field type in the name of the cookie (in this case "MyCookie").
Execute the Action by "OnLoad".
Apply the ActionGroup.action (find it in the Specials folder) to Head Action #4.
Execute the ActionGroup.action by "OnCall" and name it "MyName".
Here you add three Actions:
- SetVariable.action
- WriteCookie.action
- OpenAlertWindow.action
Apply SetVariable.action (find it in the Variables folder) as the first Action in the ActionGroup.action.
From the "Variable" pop-up choose the variable "WhatEver".
In the "Value" field you type in "true" (without the quotes).
Apply the WriteCookie.action (find it in the Variables folder) as the second Action in the ActionGroup.action.
In the "Name" field type the name of the cookie "MyCookie" (without the quotes).
In the "Expires after" field, set the timeout to one hour.
(In this case I have chosen to set the expiration to one hour, in real life you would choose a year.
(8760 hours is about a year).
Leave the other values blank.
Apply the OpenAlertWindow.action (find it in the Message folder) as the third Head Action.
Here you type in the message you'd like the visitor to be prompted with..
Note:
This third Action is the "brain" of the event you want to expose your visitor to.
The OpenAlertWindow.action can be replaced with another Action that will create an event for the visitor. You can use an Open-new-window Action or you can send the visitor to another page or use PlayScene.action or ...
Lastly, add to the Action Group the Action you want to use to display the event, as always it's only your imagination that sets the limit ;-).
Apply the Condition.action (find it in the Specials folder) to Head Action #5.
Apply to the Condition tab the TestVariable.action.
In the "Variable" popup choose the variable "WhatEver".
In the "Value" field type "true" (without the quotes).
In "Operation" popup choose "Equal" as the criteria.
Apply to the True tab the SetVariable.action.
In the "Variable" popup choose the variable "WhatEver".
In the "Value" field type in "true" (without the quotes).
Apply to the False tab the CallAction.action.
In the "Action" popup choose "MyName".
That's it!