T
T
Turik-us2014-08-18 09:09:21
User identification
Turik-us, 2014-08-18 09:09:21

How to authorize a user on a site with Wordpress?

there is a site on wrodpress.
How do I authorize a user in WordPress, without the standard functions from WordPress.
there is access to the database, i.e. all key and auth are there.
I do like this:

$time = time() + 2 * 86400000;
$data = 'adminjdwD|'.$time;
$key = '$l*gvjdCkIUb;.Sj<code>=tpvo)myKm%lBH{<e?b3_%$l2EQWO2z/iUKc|&fBO|</code>mQ>E';
$salt = 'S[[email protected]?Wa7k]qmDboI9e?K<code>mdRPg+1!w?&U)DeVf-p^0h;oD6.X+XBdYgF4^L:Y</code>C';
$key = hash_hmac('md5', $data, $key.$salt);
$hash = hash_hmac('md5', 'admin|'.$time, $key);
$cookie = 'admin|'.$time.'|'.$hash;
setcookie('wordpress_logged_in_'.md5('http://wp.ru'),$cookie,$time,'/','.wp.ru');

authorizes on the site, but does not let you into the admin panel

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
T
Turik-us, 2014-08-28
@Turik-us

$time = time() + 2 * 86400000;
$data = 'adminjdwD|'.$time;
$key = '$l*gvjdCkIUb;.Sj<code>=tpvo)myKm%lBH{<e?b3_%$l2EQWO2z/iUKc|&fBO|</code>mQ>E';
$salt = 'S[[email protected]?Wa7k]qmDboI9e?K<code>mdRPg+1!w?&U)DeVf-p^0h;oD6.X+XBdYgF4^L:Y</code>C';
$key = hash_hmac('md5', $data, $key.$salt);
$hash = hash_hmac('md5', 'admin|'.$time, $key);
$cookie = 'admin|'.$time.'|'.$hash;
setcookie('wordpress_logged_in_'.md5('http://wp.ru'),$cookie,$time,'/','.wp.ru'); //обычный юзер

for the admin is almost the same, only other cookies, another key and salt (stored in the database)
setcookie('wordpress_'.md5('http://wp.ru'),$cookie,$time,'/wp-admin','.wp.ru'); //админ

S
Slams, 2014-08-28
@Slams

Let me ask a logical question: why are built-in functions not suitable? Or do you make some kind of bridge?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question