Cakephp 2.X : External SESSION

Asked

Viewed 132 times

1

I have the following situation:

I have my application running with Cakephp 2.X, but the authentication system is external and I don’t have access to it, the only thing I was given are the $_SESSION variables provided by the server.

Is there any way to access these $_SESSION inside Cakephp? Using Framework features to get values?

EDIT 1

Using the command session_start(), Inside the View I can recover the values, but I need to recover these values in the Model...

EDIT 2

public function beforeFilter() {
        parent::beforeFilter();
        if($_SESSION['chave']){
            $this->Session->write('chave', $_SESSION['chave']);
            $this->Session->write('nmCracha', $_SESSION['nmCracha']);
            $this->Session->write('prefDep', $_SESSION['prefDep']);

        }else{
            $this->redirect('http://...../index.html');
        }
    }

1 answer

0

I don’t see the need to use Cakephp resources for this, I don’t really know if you have any native resources for this. What I advise is to use pure PHP in this case, ie working with the global $_SESSION directly. I see no problem with this.

  • Using Global helps in View and there it works, however I need to pass to the Controller, when I try to recover the value it returns me null, already of a print_r($this->Session->read()) but it does not find the values and unfortunately I do not have access to the authentication server, let alone support from the Directorate of Technology to help me...

  • And in View I can only access using session_start(), by Sessionhelper without using start I cannot recover the value!

  • Using print_r($this->Session->read()) does not solve your case, as it only reads the Cake sections. You already tried the global in the model?

  • Unfortunately it doesn’t work also it returns me Undefined variable: _SESSION

  • Post an excerpt of the code to make it clearer what you are doing. I use $_SESSION in some cases and never had a problem. Have you tried removing session_start()? Cake starts the session on its own.

  • I edited the question and posted the code used!

  • I created a gist with the code that will suit you. See here: https://gist.github.com/anonymous/bd7b2025df22d6b28489

  • Got it here, forgot to disable debug on core.php

  • Sorry for the delay, could you open the chat again?

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.