coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 permissions => Topic started by: ssimon on December 17, 2005, 01:36:38 AM

Title: How do you know when the user is log in
Post by: ssimon on December 17, 2005, 01:36:38 AM
Hello,

I want to use the coppermine's login in my website. I create a login page for my website who call the login page of my coppermine's gallery (http://mywebsite/coppermine's gallery).

I tested this code to know if the user were identified  but it doesn't work.

if (!USER_ID) {
header("Location: http://mywebsite/login.php");
}


The value of USER_ID is empty.

I tried another code
if (!$USER_DATA['user_id']) {
header("Location: http://mywebsite/login.php");
}


it's the same : the value is empty

But if I recover the value in the page of login of coppermine, it is worth 0 if the person is not identified yet.
Why i don't recover the value of $USER_DATA['user_id'] in my main page of my website ? How can i recover the information ?

Thanks

Stéphane
Title: Re: How do you know when the user is log in
Post by: cristele on September 10, 2006, 03:42:45 AM
...I have the exact same question  ::)
Title: Re: How do you know when the user is log in
Post by: Joachim Müller on September 10, 2006, 08:15:42 AM
For me, USER_ID works fine. However, what exactly are you trying to accomplish? Redirecting guests to the login page can be accomplished using the option "Allow unlogged users (guest or anonymous) access (http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#admin_allow_unlogged_access)" in coppermine's config.
I suggest posting actual code (with actual links) instead of pseudo-code.
Title: Re: How do you know when the user is log in
Post by: cristele on September 10, 2006, 08:42:00 PM
I'm trying to redirect my login page and use the coppermine login for my entire website. When logging in, the user is not automatically redirected to the coppermine gallery but remains on the main page of my personal website and can navigate thru it. (and in particular, all the pages of my website that use the coppermine gallery are already available to him since he connected first place on my website (I have several albums to show on several different pages) The website is not available for guests/anonymous.
So what I'm trying to do is re-writing the coppermine login page so it doesnt redirect to the coppermine gallery but just opens a session to the user. Does it make sense? that's why I''d like to see the USER_DATA because I need to see and welcome on my website the logged user.
For now i
m working on localhost.
Title: Re: How do you know when the user is log in
Post by: Joachim Müller on September 10, 2006, 10:52:31 PM
USER_ID is not a session var, but a constant that is being set when coppermine files are actually run. Therefor, it won't get populated on non-coppermine pages.
You have two options: make your non-coppermine pages read the cookie set by coppermine or add this code to your non-coppermine files:<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
?>
This will make your non-coppermine pages become coppermine pages in fact. Will only work for files though that reside in coppermine's root folder (because reference to subsequent includes is relative, not absolute).
Title: Re: How do you know when the user is log in
Post by: cristele on September 10, 2006, 10:56:06 PM
ok; so if I do

<?php
define('IN_COPPERMINE', true);
require('http://mycopperminelocation/include/init.inc.php');
?>

this wont work, correct? (sorry for the newbie PHP question)
Title: Re: How do you know when the user is log in
Post by: Joachim Müller on September 10, 2006, 10:59:06 PM
As I suggested: no. Don't try including URIs - that's nonsense. Use paths.
Title: Re: How do you know when the user is log in
Post by: cristele on September 10, 2006, 11:02:47 PM
Ok! thanks for your help