Closed (fixed)
Project:
Webform
Version:
5.x-2.1.1
Component:
Miscellaneous
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Jul 2008 at 21:06 UTC
Updated:
19 Sep 2008 at 16:51 UTC
My page make a cookie named "web_origen" with javascript. My webform has a hidden field with the default value set to %cookie[web_origen].
The performance setting I have set is caching mode=normal.
Everything works OK while I'm as the administrator, but when I close the session the cookie content is not loaded in the hidden field of my forms.
At the moment I have had to set caching mode=disable because in this way it works OK.
Somebody else happening?
Best regards.
Comments
Comment #1
quicksketchThis is more a limitation of Drupal than a bug with Webform. When you enable caching, it affects the way pages are displayed to anonymous users, creating a straight page-cache. If there is no cache of the page, the first anonymous user that hits that page will create the page cache, so the %cookie will work only that first time. Then the next anonymous user that hits the page will get the exact same page from opening to closing
<html>tag.So for the purposes of efficiency, correcting the problem you're reporting is not possible. It's the compromise you get when you use Drupal's page caching mechanism. Your only options are: don't use the page cache or don't use Webform's %cookie at all and figure out a different way to set the default value.
In terms of this "different way", you could use JavaScript to access user's cookies and then populate the form's default values. I've heard of several high-performance sites using a similar approach to serve out cached pages that contain semi-dynamic content.
Comment #2
solanas commentedThank you very much quicksketch. I understand you and I would try to apply the JavaScrit to populate the hidden text field.
Comment #3
mtndan commentedCould you suggest a similar alternate way to use %server[HTTP_REFERER] - see #308755: %server[HTTP_REFERER] doesn't work if caching is enabled
Comment #4
mtndan commentedOK, I figured out how to do this:
In my webform I created a markup field with the following content (requires jquery cookie module):
(Surround this code block with script tags)
$(function() { var COOKIE_NAME = 'ref_system'; var REFERER = document.referrer; $.cookie(COOKIE_NAME, REFERER, { expires: null }); $("input#edit-submitted-referring-page").val($.cookie(COOKIE_NAME)); });