Jump to content

Sessions


unidox

Recommended Posts

I am making a CMS, and I have a /core/ folder, which contains all my classes for logging in and what not. Now, i am trying to use a class that sets a login session, inside the /admin/ directory. I dont know why, but the sessions are being set. Any ideas?

 

index.php in /admin/:

 

<?php
session_start( );

// exit ( $_SESSION['userId'] );

include ("../config.php");

include ("../core/coreClass.php");
include ("../core/dbClass.php");
include ("../core/userClass.php");

define (IN_SCRIPT, true);

$coreClass = new coreClass ( );
$dbClass = new dbClass ( $host, $username, $password, $table );
$userClass = new userClass ( );

if ( !$userClass->checkLoggedIn( ) ) {
    $currentPage = "login";
} elseif ( $coreClass->getGET("page") && file_exists ( "pages/".$coreClass->getGET("page").".php" ) ) {
    $currentPage = $coreClass->getGET("page");
} else {
    $currentPage = "home";
}
@include ( "processors/".$currentPage.".php" );
include ( "pages/".$currentPage.".php" );
?>

 

Here is the function that is being called (I know its returning true) This is inside /core/:

public function loginUser ( $username, $password ) {
        $username = coreClass::clean( $username );
        $password = coreClass::encrypt( coreClass::clean( $password ) );
        
        $query = dbClass::sql ( "users", "WHERE `username` = '$username' AND `password` = '$password' AND `isActive` = '1'" );
        
        if ( mysql_num_rows( $query ) == 1 ) {
            $row = dbClass::get_row( $query );
            
            $_SESSION['userId'] == $row['id'];
            $_SESSION['isLogged'] == 1;
            $_SESSION['isAdmin'] == $row['isAdmin'];
            $_SESSION['userLevel'] == $row['accessLevel'];
            
            return true;
        } else {
            return false;
        }
    }

Link to comment
https://forums.phpfreaks.com/topic/207327-sessions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.