[resolved] Login procedure without using plugin: it seems like cookie is not set! (2 posts)

  1. Pierpaolo.EJ
    Posted 5 years ago #

    Hi guys, I'm new in wordpress and i'm trying to implement a login procedure relying only on wordpress core API.
    I don't know why this code doesn't work:
    ` ......
    $login_data = array();
    $login_data['user_login'] = $email; //i'm using email as username...
    $login_data['user_password'] = $password;
    $login_data['remember'] = $remember;
    $user = wp_signon( $login_data, false );
    } else {
    $user_id = $user->ID;
    echo "User ".$user_id." Logged in!!";`
    So, as you can see, i added some control to see if my user is actually logged in and it is! But when i move in the home page i lose my authentication, so i think there are some problem with the wp_set_auth_cookie(). For this reason i also used the wp_validate_auth_cookie() after setting cookie and i see it returns false: is it the core of the matter? Someone can help me, please? Anyways I'm sorry for my english :D

  2. Pierpaolo.EJ
    Posted 5 years ago #

    I gave up this way.... i simply passed my html login form to wp_login.php with the wp_login_url():

    <div id="site_wrap" class="core">
    				<form id="login" action="<?php echo wp_login_url( get_permalink() ) ?>" method="post">
     					<label for="log">Email:</label><input type="text" name="log" value="" />
    					<label for="pwd">Password:</label><input type="password" name="pwd" value="" />
    					<button name="submit" type="submit">Accedi</button>
            </div><!-- /end #site_wrap -->

    But i'm still curious why the wp_set_auth_cookie didn't not working...anyways i got the solution!

Topic Closed

This topic has been closed to new replies.

About this Topic