• Resolved ricksterzh

    (@ricksterzh)


    Hi,
    I just upgraded to the pro version which is using Session storage instead of Local Storage (Cookies).

    We already did a upload form in combination with WordPress File Upload Pro which uploads videos and stores data in the database.

    All the data needed were stored from the cookie with this code_

    ————-code begin

    <script type=”text/javascript”>// <![CDATA[
    wfu_addEventHandler(window, “load”, set_url_in_terms);
    function set_url_in_terms() {
    var search = “AGB”;
    var labels = document.querySelectorAll(“.file_userdata_label”);
    var sid = “”;
    var ind = “”;
    for (var i = 0; i < labels.length; i++)
    if (labels[i].innerHTML.substr(0, search.length) == search) {
    var match = labels[i].id.match(/^userdata_([0-9]+)_label_([0-9]+)$/);
    sid = (match[1] ? match[1] : “”);
    ind = (match[2] ? match[2] : “”);
    if (!(sid == “” || ind == “”)) break;
    }
    if (!(sid == “” || ind == “”)) {
    var label = document.getElementById(“userdata_” + sid + “_checklabel_” + ind);
    label.innerHTML = “Ich akzeptiere die Bestimmungen“;
    }
    }
    // ]]></script>
    ——————Code end

    Is there a possibilty to read these values from the Session, and how?

    Cheers Martin

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ricksterzh

    (@ricksterzh)

    sorry wrong code:

    <script type=”text/javascript”>
    function wfu_getCookie(name) {
    var value = “; ” + document.cookie;
    var parts = value.split(“; ” + name + “=”);
    if (parts.length == 2) return parts.pop().split(“;”).shift();
    }
    wfu_addEventHandler(window, “load”, wfu_preload_cf7msm_data);
    function wfu_preload_cf7msm_data() {
    var cookie = wfu_getCookie(“cf7msm_posted_data”);
    var data = JSON.parse(unescape(cookie));
    if (data) {
    document.getElementById(“userdata_1_field_1”).value = data.Vorname;
    document.getElementById(“userdata_1_field_2”).value = data.Nachname;
    }
    }
    </script>

    Plugin Author webheadcoder

    (@webheadllc)

    You’ll need to test this out yourself, but the session storage key is ‘cf7msm’. so something like this:

    sessionStorage.getItem('cf7msm');

    might work in place of:

    wfu_getCookie(“cf7msm_posted_data”);

    Thread Starter ricksterzh

    (@ricksterzh)

    The data is appearing in the WordPress File Upload Pro Plugin.
    Its working!

    Changed code to:

    <script type="text/javascript">
    function wfu_getCookie(name) {
      var value = "; " + document.cookie;
      var parts = value.split("; " + name + "=");
      if (parts.length == 2) return parts.pop().split(";").shift();
    }
    wfu_addEventHandler(window, "load", wfu_preload_cf7msm_data);
    function wfu_preload_cf7msm_data() {
    	var cookie = sessionStorage.getItem("cf7msm");
    	var data = JSON.parse(unescape(cookie));
    	if (data) {
    		document.getElementById("userdata_1_field_1").value = data.Vorname;
    		document.getElementById("userdata_1_field_2").value = data.Nachname;
    	}
    }
    </script>

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Read values from session storage’ is closed to new replies.