Support » Plugins » Hacks » sessions and cookies

  • This code dosen’t set the cookie (It’s not there when I look in google inspector)

    session_start();
    $psw=$_POST["psw"];
    if (strlen($psw)>0)
    {
    	setcookie("thepsw", "12345", time()+3600, '/');
    	$_SESSION["thepsw"]=$psw;
    }
    var_dump($_COOKIE);
    var_dump($_SESSION);

    It sets the session, but when I go to another wordpress screen, it has lost the session value too. I would like a solution for both if pos, please.

Viewing 1 replies (of 1 total)
  • This worked for me
    add_action(‘init’, ‘my_setcookieon’);
    function my_setcookieon()
    {
    setcookie(‘pswStatus’, “ON”, time() + 3600, COOKIEPATH, COOKIE_DOMAIN );
    }

    Thanks Mike Little for this

Viewing 1 replies (of 1 total)
  • The topic ‘sessions and cookies’ is closed to new replies.