close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Boolean Loops With Cookie Behavior

Thread began 8/11/2009 7:29 am by doublehelix3216386358 | Last modified 8/14/2009 11:14 pm by Eric Mittman | 1978 views | 5 replies |

doublehelix3216386358

Boolean Loops With Cookie Behavior

Be gentle with me, I am quite the novice... ;)

Basic scenario:

I have a page (call it "page 1") with a link to go to a form page. Once complete, this form sets a cookie, and takes users to a download page. On subsequent visits, I would like the users to be able to skip the form page altogether and go directly from "page 1" to the download page.

Through the use of your program, I have got this working, sort of, but it is not ideal.

First, I can get the form to set the cookie, that is easy. It is the redirection that is not as clean as I would like it to be.

I cannot find a way to make the original link on "page 1" send the user to the correct page based on the cookie. I would like that link to make the *decision*, cookie = "yes", go to download page, cookie = "no", go to form page.

What I ended up doing was keeping the link on "page 1" to go to the form page only, but then on the form page, I used the "Redirect based on cookie" behavior, set to "On Load" for a small graphics file on the form page, which sends the user to the download page if the cookie exists. This means that the form page starts to load, but then redirects almost immediately. This causes a bit of a jerky hitch in the transition between "page 1" and the download page for those that already have the cookie.

When I look at the code for the cookie redirection, it looks like this:

"WA_cookieRedirect(WA_CookieObj,document,true,'TB_Download_Form','1','Downloadmusic.html',false)" />

It looks like I should be able to use this code with the original link on "page 1", yet add in a value for the "false" parameter so that the original link will make the decision to do the redirection based on the cookie. I have tried several permutations of this, but I cannot seem to get it to work.

Basically, a Boolean loop... "If, then, else" type of redirection.

Is this possible with this program? If so, would you be so kind as to supply me with the correct syntax?

Thanks in advance.

Sign in to reply to this post

Eric Mittman

You are already implementing this in the correct way, you just have your redirect too far down on the page. You should move the redirect code so that it is in the head above any other script or image preloading, it can be the first thing in the head. This way the page will not load up then redirect, instead the user will click the link, the form page will attempt to load but before anything is displayed on the page at all it will go to the download page.

Sign in to reply to this post

doublehelix3216386358

Thank you Eric, however, I was unable to get your solution to work as you suggested.

I copied the following line of code to the very first line below the <head> tag:

onload="WA_cookieRedirect(WA_CookieObj,document,true,'TB_Download_Form','1','Downloadmusic.html',false)"


Nothing happened.

Do I need to enclose the line between "<" and ">" (or "/>")? Am I missing something else?

Remember, I am a novice, so you need to be *very* specific! :)

Doesn't the function:
"function WA_cookieRedirect"

need to be loaded before that command?


Also, there is no way to add this using the Behaviors window into the location you suggest. It has to be added elsewhere, and then cut and pasted into position. Not a biggie I suppose, but it would be much nicer if you could implement the Boolean logic into the command as I originally suggested.

Sign in to reply to this post

Eric Mittman

It will not work to have the onload event trigger the redirect based on the cookie because this event is only valid for the body tag.

Instead you will need to put this in a script block like this:

<script type="text/javascript">
WA_cookieRedirect(WA_CookieObj,document,true,'TB_Download_Form','1','Downloadmusic.html',false);
</script>



Make sure that you have this function defined before this line of code appears. Other than that it should load this code, check the cookie, then do the redirect.

Sign in to reply to this post

doublehelix3216386358

Thank you, that did the trick.

I really appreciate your help.

Sign in to reply to this post

Eric Mittman

No problem, I'm happy to hear that it worked out for you.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...