• Welcome to the Chevereto User Community!

    Here, users from all over the world come together to learn, share, and collaborate on everything related to Chevereto. It's a place to exchange ideas, ask questions, and help improve the software.

    Please keep in mind:

    • This community is user-driven. Always be polite and respectful to others.
    • Support development by purchasing a Chevereto license, which also gives you priority support.
    • Go further by joining the Community Subscription for even faster response times and to help sustain this space
  • Chevereto Support CLST

    Support response

    Support checklist

    • Got a Something went wrong message? Read this guide and provide the actual error. Do not skip this.
    • Confirm that the server meets the System Requirements
    • Check for any available Hotfix - your issue could be already reported/fixed
    • Read documentation - It will be required to Debug and understand Errors for a faster support response

Check if user logged in on custom pages

teejam

Chevereto Member
Hi there -

I've looked and couldn't find the answer, but is there an easy way to check if a user is logged in, and then get at least their user id to look up the rest of their details from the DB? I've tried this on on a standalone PHP script, and it functions, but it includes page styling:

PHP:
require 'app/loader.php';
if(CHV\Login::getUser()){
    // logged in
}
else{
    // not logged in
}

Thanks 🙂
 
Last edited:
It is right there... CHV\Login::getUser() returns the user array.
 
It is right there... CHV\Login::getUser() returns the user array.
Thanks. Is there a way to avoid including the theme, though? Basically I'm looking for a way to manage the session in a standalone script, separate from Chevereto aside from using its session data.
 
Thanks Rodolfo. I couldn't get that to work without the theme output, so I ended up doing the following, which seems to work great:

PHP:
<?php
define('access',true);
require($_SERVER['DOCUMENT_ROOT'] . '/lib/G/G.php');
require($_SERVER['DOCUMENT_ROOT'] . '/app/lib/classes/class.settings.php');
require($_SERVER['DOCUMENT_ROOT'] . '/app/lib/classes/class.db.php');
require($_SERVER['DOCUMENT_ROOT'] . '/app/lib/classes/class.requestlog.php');
require($_SERVER['DOCUMENT_ROOT'] . '/app/lib/classes/class.user.php');
require($_SERVER['DOCUMENT_ROOT'] . '/app/lib/classes/class.login.php');

try {
    if($_SESSION['login']) {
        CHV\Login::login($_SESSION['login']['id'], $_SESSION['login']['type']);
    } else if($_COOKIE['KEEP_LOGIN']) {
        CHV\Login::loginCookie('internal');
    } else if($_COOKIE['KEEP_LOGIN_SOCIAL']) {
        CHV\Login::loginCookie('social');
    }

} catch(Exception $e) {

}

?>
 
Back
Top