Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check for logged in user
#1
Is there a simple way/call for a plugin to know if there is an active logged session?

I wanted to set my simplecache plugin to not show cached pages to a logged in user.

Thanks in advance-

EDIT: nvm I was checking the source and it look like I just need to call cookie_check();

EDIT: Nope - thought I could just throw in a
Code:
include_once(GSADMININCPATH.'cookie_functions.php');

and then use an if(cookie_check()==FALSE) to check for no user logged in, but that isn;t working Sad

-Rob A>
Reply
#2
You'd have to use isset to check if a cookie exist, rather than checking boolean value of cookie_check() function.
Anyway, you won't check it without knowing name of the cookie, and it's not that simple, as the name contains the salt value.
Something like: getsimple_cookie_203rwzy^|epaw*ekf7zuj2m3o4ga3o~fw5tbatt

Maybe just looking if a cookie starting with "getsimple_cookie_" chars exist and is not null would be enough ?
Addons: blue business theme, Online Visitors, Notepad
Reply
#3
yojoe Wrote:You'd have to use isset to check if a cookie exist, rather than checking boolean value of cookie_check() function.
Anyway, you won't check it without knowing name of the cookie, and it's not that simple, as the name contains the salt value.
Something like: getsimple_cookie_203rwzy^|epaw*ekf7zuj2m3o4ga3o~fw5tbatt

Maybe just looking if a cookie starting with "getsimple_cookie_" chars exist and is not null would be enough ?

Well, I've looked at a couple of plugins:
http://get-simple.info/forum/post/6074/#p6074
and
http://get-simple.info/extend/plugin/edi...plugin/26/

The first hooks into login/logout and sets/checks its own cookie.

The second duplicates some of the stuff in the cookie_check() function.

Any guidance on what is better?

EDIT: Looks like I can't include configuration.php in the pre and post template hooks, I end up with an error:
Code:
Notice: Undefined variable: site_full_name in /public_html/admin/inc/theme_functions.php on line 150

Notice: Undefined variable: site_version_no in /public_html/admin/inc/theme_functions.php on line 150

-Rob A>
Reply




Users browsing this thread: 1 Guest(s)