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

Cookie, show region if value is... not works first load page in the browser.

Thread began 6/30/2016 3:49 am by Mike | Last modified 6/30/2016 3:03 pm by Ray Borduin | 257 views | 4 replies |

Mike

Cookie, show region if value is... not works first load page in the browser.

Hello,
I'm using a cookie value to view a region in a web page.

This is the code generated with "Utilities, Show Region Utility" from latest version of DataBridge:
<?php
if ("".((isset($_COOKIE["product"]))?$_COOKIE["product"]:"") ."" == "nameproduct") {
?>
<p>test</p>
<?php
}
?>

The behavior is:
If the cookie "product" has value "nameproduct", show "<p>test</p>".

The problem is that works good only after two refresh in the page.
Indeed, if the user open the page the first time (or close and re-open the browser) the "show region" not works.

Any ideas to resolve this issue?
Thanks,
Michele

Sign in to reply to this post

Ray BorduinWebAssist

Please attach a copy of the page and I'll see if I can spot the problem.

Sign in to reply to this post

Mike

Hi Ray,
I've attached a copy of the page.

Thanks,
Michele

Sign in to reply to this post

Ray BorduinWebAssist

You are setting the cookie on the client which occurs after the page loads and the server code has run once. Since it appears you need to use javascript to check the country, you would have to also use javascript instead of php to hide or show the content on this page. Something like:


<body>
<div id="hideorshow" style="display:none;">
<p>test</p>
</div>
<script>
if (geoplugin_countryName() == 'Italy') {
document.cookie = "country=italy";
document.getElementById().style.display = "block";
} else {
document.cookie = "country=other";
}
</script>
</body>

On future pages, after the cookie has been set, you can use the php method to hide or show contents.

Sign in to reply to this post

Mike

Great!
Thanks Ray!

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...