Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changes to cookiecheck?
#1
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>
Reply
#2
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!
Reply
#3
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>
Reply
#4
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!
Reply
#5
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>
Reply
#6
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);
      }
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#7
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>
Reply
#8
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!
Reply
#9
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>
Reply
#10
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!
Reply




Users browsing this thread: 2 Guest(s)