Posts: 290
Threads: 26
Joined: Oct 2010
My clientfiles plugin used this code in a separate php download helper file:
Code:
# Include common.php
include('../../admin/inc/common.php');
$loggedin = cookie_check(); //check admin login
followed by
Code:
if ($loggedin===TRUE) // logged in
to check if the admin is logged in, and then serve up a file.
This seems to be broken in GS3. Is there a better way to check for admin login?
-Rob A>
Posts: 1,848
Threads: 86
Joined: Aug 2009
I dont think there have been any changes to the way we check for the cookie in a very long time:
http://code.google.com/p/get-simple-cms/...ons.php#59
i see nothing wrong with your code example assuming that you are linking to common.php correctly...
-
Chris
Thanks for using GetSimple! - Download
Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Posts: 290
Threads: 26
Joined: Oct 2010
Well, I'm at a loss.
I added some debug code after cookie_check():
Code:
global $USR;
global $SALT;
global $cookie_name;
var_dump($USR);
var_dump($SALT);
var_dump($cookie_name);
and it seems $USR is null. I'm guessing this may be due to the new multi-user code...
Rather than trying to use this core function I think I'll just have to create my plugin's own cookie on login hook and destroy it on logout hook.
-Rob A>
Posts: 1,848
Threads: 86
Joined: Aug 2009
Rob, after doing some troubleshooting yesterday, i am seeing a problem as well:
http://code.google.com/p/get-simple-cms/...?id=186#c0
stay tuned...
-
Chris
Thanks for using GetSimple! - Download
Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Posts: 290
Threads: 26
Joined: Oct 2010
ccagle8 Wrote:Rob, after doing some troubleshooting yesterday, i am seeing a problem as well: http://code.google.com/p/get-simple-cms/...?id=186#c0
stay tuned...
I tried the SVN version... still no work with my code (that DID work in the previous GS version...)
-Rob A>
Posts: 2,094
Threads: 54
Joined: Jan 2011
The problem is the
GS_ADMIN_USERNAME cookie, which does not honor
GSCOOKIEISSITEWIDE. In
login_functions.php replace
Code:
setcookie('GS_ADMIN_USERNAME', $USR);
with
Code:
if (defined('GSCOOKIEISSITEWIDE') && (GSCOOKIEISSITEWIDE == TRUE)) {
setcookie('GS_ADMIN_USERNAME', $USR, 0, '/');
} else {
setcookie('GS_ADMIN_USERNAME', $USR);
}
Posts: 290
Threads: 26
Joined: Oct 2010
Quote:The problem is the GS_ADMIN_USERNAME cookie, which does not honor GSCOOKIEISSITEWIDE. In login_functions.php replace
You are the bees knees! That fixes it!
I'm hoping this fix gets into the main code...?
-Rob A>
Posts: 1,848
Threads: 86
Joined: Aug 2009
i will definitely fix this in the SVN - one question though:
is there any reason not to make GSCOOKIEISSITEWIDE the default? Why wouldnt we want the cookie always to be sitewide in the first place?
-
Chris
Thanks for using GetSimple! - Download
Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Posts: 290
Threads: 26
Joined: Oct 2010
In my case (the client file plugin) I use it to check if the admin is logged in to authorize downloading files.
The only other plugin I've seen that uses it is one that adds "EDIT" links to each page when viewing the front end and logged in.
I guess you could also use it to display "Private" pages when logged in, or something.
I can't think of a reason NOT to.
-Rob A>
Posts: 1,848
Threads: 86
Joined: Aug 2009
RobA Wrote:I can't think of a reason NOT to.
i agree... i would like to hear from others too though...
-
Chris
Thanks for using GetSimple! - Download
Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!