How do you know when the user is log in How do you know when the user is log in
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

How do you know when the user is log in

Started by ssimon, December 17, 2005, 01:36:38 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ssimon

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

cristele


Joachim Müller

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" in coppermine's config.
I suggest posting actual code (with actual links) instead of pseudo-code.

cristele

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.

Joachim Müller

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).

cristele

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)

Joachim Müller

As I suggested: no. Don't try including URIs - that's nonsense. Use paths.

cristele