我正在尝试从PHP
本机会话启动的会话中读取和写入。我找到了有关它的信息,但实际上我无法与此会话进行交互。我用了这两个文件:
http://symfony.com/doc/current/components/http_foundation/session_php_bridge.html
http://symfony.com/doc/current/cookbook/session/php_bridge.html
如果我理解得很好,我应该能够在PhpBridgeSessionStorage
启动后获得此会话的属性?如果是这样,我只得到一个空数组。
以下是我编码的方式:
public function indexAction(Request $request)
{
//I get my service, execute and then the session is created.
$phpCas = $this->container->get('phpcas');
$phpCas->execute();
// I start a new Session and display what's inside
$session = new Session();
$session->start();
$array = $session->all();
echo "<pre>";
print_r($array);
echo "</pre>";
return;
在我的服务中,我开始像这样的php桥接会话:
public function execute()
{
require_once __DIR__ . '/source/config.php';
ini_set('session.save_handler', 'files');
ini_set('session.save_path', '/tmp');
session_start();
phpCAS::setDebug();
phpCAS::client(SAML_VERSION_1_1, $cas_host, $cas_port, $cas_context);
phpCAS::setCasServerCACert($cas_server_ca_cert_path);
phpCAS::handleLogoutRequests(true, $cas_real_hosts);
//In forceAuthentication(), this is going to
start again a session and create a cookie.
phpCAS::forceAuthentication();
//I start a new phpBridgeSessionStorage to interact with this session
$session = new Session(new PhpBridgeSessionStorage());
$session->start();
}
在我的app / config.yml中,我写了这个:
session:
storage_id: session.storage.php_bridge
handler_id: ~
save_path: null
我正在使用Linux
,是否有读/写/tmp
权限的问题?或者是我不理解文档并且没有正确编写我的代码以使其交互?
感谢您的帮助