K
K
kapitansen2021-08-10 11:41:59
Phalcon
kapitansen, 2021-08-10 11:41:59

How to get phalcon session data in another class method?

The question is most likely more about OOP, but it so happened that my deep OOP started with a legacy project on Phalcon.

The IndexController class has this:

namespace manage\controllers;

use common\models\ScrapedVideos;
use common\types\VideoStatusType;
use manage\models\AdminUsers;
use manage\models\UserVideos;

class IndexController extends ManageController
{

    public function loginAction()
    {

            if (!$this->session->isStarted()) {
                $this->session->start();
            }

            $this->session->set('adminUser', $admin);
            return $this->response->redirect('/manage/index/index/');
        }

        return $this->view;
    }
}


And then I need to get $this->session->get('adminUser') inside this one:

namespace manage\models;

use common\helpers\SessionHelper;
use common\models\CollectionRepository;
use common\models\FavoriteUserVideos;
use common\models\Thumb;
use common\models\UserVideosVotes;
use DateTime;
use manage\components\CdnFtpClient;
use Phalcon\Db\Adapter\Pdo\Mysql;
use Phalcon\Di;
use Phalcon\Logger\Adapter\File;

class UserVideos extends \common\models\UserVideos
{
    public function deleteVideo($id)
    {
         $removedBy =  $this->session->get('adminUser');
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question