Log-In the User with Lightopenid

Log-in the user with LightOpenID

This script is now working fine from my localhost running apache on my laptop with a wifi connection to the internet.

I've been told that you should pass your domain to the new LightOpenId object when creating it.

$iniConfig is a parse_ini_file array stored outside the document root where I store all my important variables.

in this case

[openid] 
domain='mydomain.com'

So, I create new object and include the domain the server is on:

$openid = new LightOpenID($iniConfig['openid']['domain']);

I wrote it this way, and haven't checked to see if it works without the domain..

Log-in/log-out user status with LightOpenID

Your question has actually nothing to do with OpenID.

OpenID is an authentication protocol, meaning that it only checks whether the user really is who he claims to be -- in the same sense that asking for a password checks that. It has nothing do to with your user being logged in or out.

In order to keep track of your user's session you need to, well, use sessions. For example, after validation:

<?php
if($openid->validate()) {
// User has logged in
$_SESSION['identity'] = $openid->identity;
}
?>

Then when you want to check whether your user is logged in (and who is he):

<?php
if(isset($_SESSION['identity'])) {
echo 'User is logged in as ' . $_SESSION['identity'];
} else {
echo 'User isn\'t logged in';
}
?>

And for the sake of completion, when logging out:

<?php
unset($_SESSION['identity']);
session_destroy();
?>

If you don't know how to use sessions, you can find more information in the manual.

LightOpenID not detecting login causing login looping

This was due to a htaccess error. Make sure you have it configured correctly if you have this problem.

Automatic login with LightOpenID after first authentication?

Turns out I just needed to send the user to our OpenID login URL instead of our homepage.

How can I know that a user really login using OpenID or just pasting the URL from the previous login?

$openid->validate() will return true only once per authentication. If an user attempts to login again using the exact same url (i.e. same nonce, etc.), $openid->validate() will return false. At least that's the case if the provider works according to the spec. If it doesn't, there's almost nothing you can do.

How to use open id as login system

You can use the PHP OpenID library here or for PHP 4 here

How to fetch account data from a provider with LightOpenID?

You need to call getAttributes() after $openid->validate() not before.

Remember:

Note that it does not guarantee that any of the required/optional parameters will be present



Related Topics



Leave a reply



Submit