Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7996019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:35:36+00:00 2026-06-04T14:35:36+00:00

I have this function in my PHP : setcookie(UserPusser, $user, time() + 604800, /pusser/beta/);

  • 0

I have this function in my PHP :

setcookie("UserPusser", $user, time() + 604800, "/pusser/beta/");
setcookie("PassPusser", $pass, time() + 604800, "/pusser/beta/");
setcookie("NotifPusser", $notif, time() + 604800, "/pusser/beta/");

And I have this function in my javascript

function getThisCookie(name){
    var value;
    var singleCookie = document.cookie.split(";")
    for(var x in singleCookie){
        var y = singleCookie[x].split("=");
        if(y[0] == name) {
            value = y[1];
        }
    }
    return value;
}

When I type alert(getThisCookie('UserPusser')) the result is what I want. But when I tried to write alert(getThisCookie('NotifPusser')); or alert(getThisCookie('PassPusser')); the result is : undefined.

Anyone can help me?

What I’m trying to do is make the browser remember the value of checkbox each time the page reload.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:35:38+00:00Added an answer on June 4, 2026 at 2:35 pm

    Just for completeness a full answer here instead of only the hint within the comments:

    Cookie values are separated by ; (semicolon + whitespace)
    This leaves you with something like this:

    cookie = 'a=123; b=456; c=678'
    

    In order to separate them you have to split them by the same delimiter.
    With modern browsers (JS 1.6+ I guess, not quite sure right now) or libraries like underscore.js you could as well put them into an object.

    // if your browser supports 'reduce'
    var cookieObject = document.cookie.split('; ').reduce(function(o, kvp) {
      var split_kvp = kvp.split('=');
      o[split_kvp[0]] = split_kvp[1];
      return o;
    }, {});
    
    // underscore.js version
    var cookieObject = _.reduce(document.cookie.split('; '), function(o, kvp) {
      var split_kvp = kvp.split('=');
      o[split_kvp[0]] = split_kvp[1];
      return o;
    }, {});
    

    Anyway after performing any of those you can easily access the values you are looking for:

    cookieObject.a == 123
    cookieObject.b == 456
    

    Just remember that those are readOnly. In order to modify them you’d have to write the object back to the document.cookie

    // again, modern browser version
    document.cookie = Object.keys(cookieObject).map(function(key) {
      return key + '=' + cookieObject[key];
    }).join('; ');
    
    // with underscore.js
    document.cookie = _.chain(cookieObject).keys().map(function(key) {
      return key + '=' + cookieObject[key];
    }).value().join('; ')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this set of codes $user = htmlentities($_POST['user']); $pass = htmlentities($_POST['pass']); function sha512($str)
I have this problem whereby, i have created a user defined function within php.
this is function.php of a wordpress theme that NOD32 says this code have a
i have this strange problem with the PHP function CTYPE_ALNUM if i do: PHP:
I have this code: function submitTwice(f){ f.action = 'http://mydomain.com/threevideopage.php'; f.target='name'; f.submit(); } I left
I have this part of code in my functions.php: function cc_admin_enqueue_scripts($hook) { $file_dir=get_bloginfo('template_directory'); wp_enqueue_script('media-upload');
I have this in my class When the second function is called php errors
I have this code in userpage.php: <script langauge=JavaScript><!-- function newWindow(fileName,windowName) { msgWindow=window.open(fileName,windowName); } //--></script>
i have created a module with this among others this function in it: <?php
I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.