Support » Fixing WordPress » Where is wordpress_test_cookie set?

  • Resolved LesTexas60

    (@lestexas60)


    I am having a nightmare of a time setting a cookie in a page of my site. Does anyone know what file “wordpress_test_cookie” is set in?
    If I can find that I should be able to set my own cookie.
    hanks for any help or suggestions.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    The test cookie is set by the login process, to test if your browser is set properly to allow cookies, which WordPress needs.

    I understand this. I am trying to find out what file contains the instructions to set the cookie. I want to see how they are completing this process.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    It’s in wp-login.php and there’s no magic trick to it. It just uses the PHP function setcookie.

    Thank you. I keep trying to do the same thing from the bottom of the functions.php file of my theme and the cookie will not set. I have multiple themes on the site, I wonder if that is affecting it.

    You sound like you have done this before. Any suggestions from my code below.
    function set_new_cookie() {
    setcookie(‘SESSIONKEY’, ‘W8NNNBTG’, time()+3600, ‘/’, ‘.lesliee.com’, false,false);
    setcookie(‘PARTNERID’, ’24’, time()+3600, ‘/’, ‘.lesliee.com’, false,false);
    }
    add_action( ‘init’, ‘set_new_cookie’);

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Well, you have SESSIONKEY and PARTNERID in quotes, so if those are supposed to be defined variables somewhere, then that’s wrong. But other than that, it looks about right.

    Your domain doesn’t need to start with a period anymore. Modern browsers should handle normal domain names just fine.

    Other than that, just check to make sure nothing is creating output before init. Should work fine.

    Those are the names of the cookies. I removed the quotes to see if that worked , no luck.
    Question. Can I set a cookie in one website that will be read in another site?
    I am hyperlinking from one site to another. The new site needs a password in order to go to the page. I am trying to pass the password from site one to site 2 using the cookie value.

    Is there a problem with this approach?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Question. Can I set a cookie in one website that will be read in another site?

    No. Cookies can only be set for the same domain that the page itself is being served from. If you need to set a cookie for another domain, you need to have a page on that domain actually set the cookie.

    Thanks Samuel, that kind of defeats my whole purpose of using the cookie.:) I suppose I assumed since one of the setting was the domain, that it would be possible to put another domain in that setting so it could be called.

    Thanks for all the help everyone.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Where is wordpress_test_cookie set?’ is closed to new replies.