2

I've created a custom login box. I'm using wp_signon() method. Everything works well.

Also i have a Remember me checkbox so i can remember user credentials next time. I know i can do it my own way of handling cookies but i want know is there any wordpress builtin method to get cookies.

This is my code so far:

$creds['user_login'] = $user_login;
$creds['user_password'] = $user_pass;
$creds['remember'] = ($remember_me === "true") ? true : false;

$user = wp_signon( $creds, false );

I can see auth cookies on Firebug Cookies tab but they are appended with hashes. How can i decrypt them or any safer method to get cookies. I've also seen in utils.js and there are some methods to get and set cookies but it only gets plain text cookies. (Correct me if iam wrong).

Simply i want the data that Wordpress has stored in the cookies when logged in. After logout and return to my login box it can fill my login box with username and password (Like wordpress default login page).

  • It isn't clear what you are trying to do. WordPress will "remember" a user by means of a time limited cookie. How is that different from what you want to do? Honestly, it sounds a bit like you are trying to subvert WordPress login security by saving plain text passwords. – s_ha_dum Jan 4 '14 at 15:18
  • @s_ha_dum Simply i want the data that Wordpress has stored in the cookies when logged in. After logout and return to my login box it can fill my login box with username and password (Like wordpress default login page). – Rahil Wazir Jan 4 '14 at 15:22
  • So you do want to save the plain text password? Don't do that. How does the site know when your return vs. when someone else returns? If you aren't logged in how do you distinguish users? And how is this better than just setting a very long expiration on the existing login cookie? – s_ha_dum Jan 4 '14 at 15:27
  • No @s_ha_dum you're not getting it. When checked remember me and logged in, Wordpress store secure cookies and i want that cookies for my login page so i don't have to type username password again. Actually those cookies are secure so it changes everytime. – Rahil Wazir Jan 4 '14 at 15:31
  • I can't really "try it myself" you haven't posted working code, just a small snippet. – s_ha_dum Jan 4 '14 at 15:43
4

if you are logged in wp_parse_auth_cookie(LOGGED_IN_COOKIE); will return array consisting wp user name, cookie hash and expiration time. This function will return null if you are not logged in. But you cannot get plain password as wordpress doesn't store plain password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.