Creating cookies on login
I’m running the usermeta and userextra plugins to provide extra information in users’ profiles. I want this information to be stored inside a WordPress session/cookie so that I can pull this information in other scripts elsewhere on my site. I found that in the wordpress codex it says that WordPress users cookies to store this information. The function to create these cookies is in the ‘/wp-includes/pluggable-functions.php’ file.
I went into the function and created an additional setcookie statement inside the function to create a test dummy cookie and nothing happened. I’ve refreshed and removed the cookies and still cannot figure out why the other two cookies (for username and password) will create while my little test cookie won’t. Any ideas on how to get an extra cookie to create on login?
Here’s part of the code I’m using, this is inside the wp_setcookie function:
if ( $remember )
$expire = time() + 31536000;
$expire = 0;
setcookie(USER_COOKIE, $username, $expire, $cookiepath, COOKIE_DOMAIN);
setcookie(PASS_COOKIE, $password, $expire, $cookiepath, COOKIE_DOMAIN);
setcookie(‘UserMetaZip’, ‘Test’, $expire, ‘/’, COOKIE_DOMAIN);
Not a clue, but I am trying to figure out how to make my users’ sessions expire, so they will have to login again periodically. (Login Logger plugin)
Okay, well, I think I figured out why your cookie generation is not working. I’m using the latest version of WordPress (2.2.2). Assuming ‘pluggable.php’ in 2.2.2 is the same as ‘pluggable-functions.php’ there is a comment at the top of the file that reads:
/* These functions can be replaced via plugins. They are loaded after plugins are loaded. */
You may have a plugin installed thats overriding the function that you’re trying to edit. It’d probably be simpler to make a plugin or alter the function of the plugin that’s overriding the default function. Just to check, try dissabling all your pluggins. If I’m correct, you should then see the expected cookie to appear.
- The topic ‘Creating cookies on login’ is closed to new replies.