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');
}
}
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...– AComerlatto
And in View I can only access using
session_start()
, by Sessionhelper without using start I cannot recover the value!– AComerlatto
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?
– Danilo Miguel
Unfortunately it doesn’t work also it returns me
Undefined variable: _SESSION
– AComerlatto
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.
– Danilo Miguel
I edited the question and posted the code used!
– AComerlatto
I created a gist with the code that will suit you. See here: https://gist.github.com/anonymous/bd7b2025df22d6b28489
– Danilo Miguel
Got it here, forgot to disable debug on
core.php
– AComerlatto
Let’s go continue this discussion in chat.
– Danilo Miguel
Sorry for the delay, could you open the chat again?
– AComerlatto