close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How do I show cookie value without reload the page?

Thread began 8/12/2013 3:27 am by info4753 | Last modified 9/30/2016 12:15 pm by Ray Borduin | 15869 views | 17 replies |

info4753

How do I show cookie value without reload the page?

I have a two page form. When I set a cookie with the following code:

<?php
if (isset($_POST["button"]) || isset($_POST["button_x"])) {
setcookie("cookTest", "".((isset($_POST["Entry"]))?$_POST["Entry"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}
?>

I need to do a manually reload the 2nd page in order to show up the value.

When I use this code

<?php
if (isset($_POST["button"]) || isset($_POST["button_x"])) {
$_COOKIE['cookTest'] = ((isset($_POST["Entry"]))?$_POST["Entry"]:"");
setcookie("cookTest", "".((isset($_POST["Entry"]))?$_POST["Entry"]:"") ."", time()+(60*60*24*30), "/", "", 0);
}
?>

The cookies are set on the 2nd page but when I go back to the first page, I nedd again to reload the page manually. How can I avoid the manual reload on the first page?

Sign in to reply to this post

info4753

This post has been deleted.

Jason ByrnesWebAssist

You shouldn't need to reload the page, can you provide a link where i can see the problem and a copy of the pages please?

Sign in to reply to this post

info4753

I guess I've solved the problem. But thanks for replying to the thread ;-)

Sign in to reply to this post

Jason ByrnesWebAssist

ok, glad to hear it is working.

Sign in to reply to this post

vernon webb

I have this problem on this page:

http://dev.rsavvy.com/order_search.php

If you set the cookie it does not hold unless you reload the page.

Sign in to reply to this post

Ray BorduinWebAssist

You could manually register the cookie in the cookie array when it is set like:

$_COOKIE['cookTest'] = "cookie value";

Sign in to reply to this post
Did this help? Tips are appreciated...

vernon webb

Sorry got side tracked. I'm not sure I know what you mean. I am using Webassist to set the cookie value...

Sign in to reply to this post

vernon webb

Just so we are clear. I am setting cookies on the above mentioned link. The results of a search are being posted to the same page. I want to retain values of the form being submitted using those cookies but when the page is submitted they are not displayed. If I refresh that page or leave that page and come back the cookies are there. So the cookies are being set but for some reason not being shown until that page is revisited. I need them to be immediately. Thoughts?

Sign in to reply to this post

Ray BorduinWebAssist

I think if you used client side (javascript) cookie references on the page it will show immediately.

<script>
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length,c.length);
}
}
return "";
}
</script>



<script>document.write(getCookie('cookiename'));</script>
Sign in to reply to this post
Did this help? Tips are appreciated...
loading

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