Set GallerySid cookie with embeded login

iearn

Joined: 2006-12-20
Posts: 22
Posted: Mon, 2007-03-26 13:37

Hi,

I am using a single login script that so that a user goes to one login page and and it logged-in to both our CMS and gallery2 at the same time. This works perfectly and users are logged into both sites.

What I need is a way to do a gallery2 API call to set the GallerySID cookie in the browser as soon as my script logs them into our site. Right now it is only setting that cookue once the users visits a gallery page, and I need it to be set the cookie without them visiting to gallery 1st.

I have searched the forums, the codex and documentation, and the web as a whole and have been unable to find the code to do what I need. Can someone please provide me with the code snippet that I would need to accomplish this? Thank you in advance for all your assistance.

iEARN

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2007-03-26 14:36

use GalleryEmbed::init(array('fullInit' => true, ......); GalleryEmbed::done().
or use GalleryEmbed::login(...);

see:
development -> embedding

--------------
Doumentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
iearn

Joined: 2006-12-20
Posts: 22
Posted: Mon, 2007-03-26 19:44

Hello Again,

Thank you valiant for your response. You have been helpful to me in the past. I seem to still be lost.

Right now I have a script that is supposed to set the cookie. I have read through the development section as you suggested, but can't find code that sets the cookie. I found one for example that gets an image block, but a test proved that using it, no cookie is set until I click the image.

My current page's code is as follows

<?php
include('embed.php');
$ret = GalleryEmbed::init(array('fullInit' => true)); // and other params if necessary
 if ($ret) {
     return $ret;
exit;
 }
GalleryEmbed::done();
?>

I think this should initialize gallery2, beyond that I am stumped. If anyone could give me a little more direction it would be greatly appreciated. Is there a GalleryEmbed::SetCookie ?? or something similar to that? I have a feeling I am missing something very simple to set the cookie. Thank you in advance for all your help.

iEARN

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2007-03-27 01:24

before you can use that stuff, you need to map your users to gallery's users.

once you've done that, you can do:

$ret = GalleryEmbed::init(array('fullInit' => true));
if ($ret) { die('An error occurred'); }
$ret = GalleryEmbed::login($userIdFromYourApplication);
if ($ret) { die('An error occurred'); }
$ret = GalleryEmbed::done();
if ($ret) { die('An error occurred'); }

--------------
Doumentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
iearn

Joined: 2006-12-20
Posts: 22
Posted: Tue, 2007-03-27 14:08

Hi,

Thank you very much. It worked like a charm.

iEARN

 
iearn

Joined: 2006-12-20
Posts: 22
Posted: Thu, 2007-07-05 19:48

Hi,

The code above works. However it seems that sometimes (so far it seems randomly) it is unable to set a cookie for a user. Is there any way to know why it could not set the cookie? Does g2 have any more detailed error logging? Could it be advised to create some sort of loop that tells the script to try and set the cookie a few times and then if it can't to have it direct the user to a login page. Any hints would be appreciated.

IEARN