|
|||||||||
|
|||||||||
![]() |
![]() |
Cookie ExampleThis page demonstrates the use of cookies to customize the user experience in Conversant. Click on one of the buttons below to change the color of the box...
This is accomplished using Conversant's #setCookie and #cookie macros, and the 'cookie.[xxx].exists' conditional macro. This page contains a form with buttons that have javascript onClick events that post you to another page. The red button posts to the 'setRed' page, and the blue button posts to the 'setBlue' page. The form code is:
The 'setRed' page is a bound message with the following content:
The form button redirects your browser to a different page. This page uses the #setCookie macro to set a cookie value, then redirects back to this page using the #redirect macro. If you are using Internet Explorer, this page does not call the redirect macro, because for some reason IE/Windows does not accept cookies along with a redirect ( IE/Mac and most other browsers do ). In order to workaround the IE/Win behavior, the 'setRed' page has the following template, that will force the browser back to the original page without sending a redirect to the cookie is stored:
The 'setBlue' page is essentially the same, but sets the cookie value to 'blue' in the #setCookie macro. Then, in this page, the box above is included using the following code:
This code first tests for the existence of the cookie using the 'cookie.[cookieName].exists' macro. If it doesn't exist, the box defaults to black. If it does, the value of the cookie is used as the background-color in the style of the box.
|
![]() |
||||||