Hi guys,
I wonder if you can help..
I am trying to allow seamless login from my main CMS (App 1) to zen photo.
Ideally once the user has logged into the main CMS they should not have to re-login to Zen Photo.
I can set it so both passwords are the same however how whenever I try to link to /zen/admin.php using the below script i get an error saying problem with login.
I am passing variables 'user', 'pass', 'redirect' and 'login' as you can see from my test script but still no joy..
Is there any special thing about zen photo admin page / login i need to know about?
Thanks for your help..
TEST CODE
END TEST CODE
Okay, that won't work because you're loading it within PHP.... the cookie needs to be set on the user's system to work, so the [i]user[/i] has to load the url, not the server.
Take a look at /zen/auth-zp.php, it's short, sweet, well-documented and easy to read. Do what it does in reverse to set the "zenphoto_auth" cookie manually, that'd be my suggestion. You have to set the same $cookiepath, but that's all you have to get right essentially. The hash in the cookie is just md5($adminuser . $adminpass); (the dot is a concatenation). So all you have to do is this:
`$user = "username";
$pass = "password";
$cookiepath = "http://www.yoursite.com/zenphotodir"; // Same as WEBPATH
setcookie("zenphoto_auth", md5($user . $pass), time()+5184000, $cookiepath);`
Also note this only works if you're on the same domain as your ZP installation. Otherwise you'll need the user to load auth-zp.php somehow, maybe with a JavaScript call.