Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


zf2 read http cookie


zf2 read http cookie  using -'php,zend-framework,cookies,http-headers,httpresponse'

I have a file (caller.php) which create a cookie in HTTP response and then redirect to a controller in a ZF2 application (LoginController).

caller.php

setcookie("_ga", "GA1.2.1622977711.1433494392");
setcookie("_gat", "1");

header("Location: http://gnsys.local/publico/login");


LoginController

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Http\Response;

class LoginController extends BasePublicController{

public function indexAction(){

    $response = $this->getResponse();

    foreach ($response->getHeaders() as $header) {
        echo "Campo: " . $header->getFieldName() . ' with value ' . $header->getFieldValue() . "<br />";
    }


    return new ViewModel();
}
}


When LoginController is called, I haven't got any header from the HTTP response :((

What am I doing wrong? Why I can't read any value from my http response headers? How can I read all the headers from HTTP Response?

If I do what I want but just only using PHP, LoginController is changed by a file called login.php whith this code:

foreach (getallheaders() as $name => $value) {
    echo "$name: $value</br>";
}


And this code works fine and give me what I want!!! How can I get the same in Zend Framework 2?

Please, help me!!!

Thanks in advance,

José Carlos
    

asked Oct 23, 2015 by kotmus2002
0 votes
6 views



Related Hot Questions



Walkin Jobs Opening



Government Jobs Opening


...