GetSimple Support Forum
Changes to cookiecheck? - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Developer Discussions (http://get-simple.info/forums/forumdisplay.php?fid=8)
+--- Thread: Changes to cookiecheck? (/showthread.php?tid=1500)



Changes to cookiecheck? - RobA - 2011-03-31

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>


Changes to cookiecheck? - ccagle8 - 2011-03-31

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/source/browse/trunk/admin/inc/cookie_functions.php#59

i see nothing wrong with your code example assuming that you are linking to common.php correctly...


Changes to cookiecheck? - RobA - 2011-03-31

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>


Changes to cookiecheck? - ccagle8 - 2011-03-31

Rob, after doing some troubleshooting yesterday, i am seeing a problem as well: http://code.google.com/p/get-simple-cms/issues/detail?id=186#c0

stay tuned...


Changes to cookiecheck? - RobA - 2011-04-02

ccagle8 Wrote:Rob, after doing some troubleshooting yesterday, i am seeing a problem as well: http://code.google.com/p/get-simple-cms/issues/detail?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>


Changes to cookiecheck? - mvlcek - 2011-04-05

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);
      }



Changes to cookiecheck? - RobA - 2011-04-05

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>


Changes to cookiecheck? - ccagle8 - 2011-04-05

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?


Changes to cookiecheck? - RobA - 2011-04-05

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>


Changes to cookiecheck? - ccagle8 - 2011-04-05

RobA Wrote:I can't think of a reason NOT to.
i agree... i would like to hear from others too though...