single sign on php code example
Example 1: single sign on php script
<?php
$MySecretKey = 'Nobody Will Ever Guess This!!';
$sig = hash(
'sha256',
$user->id . $user->email,
$MySecretKey
);
$source = parse_url($_GET['source']);
if(in_array($source->host, $list_of_safe_hosts))
$target = 'http://'.$source->host.$source->path;
header('Location: '.$target.'?'.
'user_id='.$user->id.
'&user_email='.urlencode($user->email).
'&sig='.$sig);
?>
Example 2: single sign on php script
<a href='http://login.example.com/login.php?source=my.other.site.com/foo/bar'>log in!!</a>