Commit 7c62ea27 authored by Fabien Potencier's avatar Fabien Potencier

merged branch ujimaesteve/patch-1 (PR #302)

Commits
-------

066e7299 Update doc/providers/session.rst

Discussion
----------

Update doc/providers/session.rst

To solve #297 and #299

---------------------------------------------------------------------------

by igorw at 2012-04-06T14:06:05Z

Looks good 👍.

Not sure if we should move session->start to a before filter.

---------------------------------------------------------------------------

by jaywilliams at 2012-04-16T18:55:51Z

I'm glad I found this pull request, because I couldn't figure out why the stated code in the documentation wasn't working.
parents 6f86f537 066e7299
...@@ -18,7 +18,7 @@ Parameters ...@@ -18,7 +18,7 @@ Parameters
* **name**: The cookie name (_SESS by default) * **name**: The cookie name (_SESS by default)
* **id**: The session id (null by default) * **id**: The session id (null by default)
* **lifetime**: Cookie lifetime * **cookie_lifetime**: Cookie lifetime
* **path**: Cookie path * **path**: Cookie path
* **domain**: Cookie domain * **domain**: Cookie domain
* **secure**: Cookie secure (HTTPS) * **secure**: Cookie secure (HTTPS)
...@@ -59,6 +59,7 @@ example that authenticates a user and creates a session for him:: ...@@ -59,6 +59,7 @@ example that authenticates a user and creates a session for him::
$password = $app['request']->server->get('PHP_AUTH_PW'); $password = $app['request']->server->get('PHP_AUTH_PW');
if ('igor' === $username && 'password' === $password) { if ('igor' === $username && 'password' === $password) {
$app['session']->start();
$app['session']->set('user', array('username' => $username)); $app['session']->set('user', array('username' => $username));
return $app->redirect('/account'); return $app->redirect('/account');
} }
...@@ -70,6 +71,7 @@ example that authenticates a user and creates a session for him:: ...@@ -70,6 +71,7 @@ example that authenticates a user and creates a session for him::
}); });
$app->get('/account', function () use ($app) { $app->get('/account', function () use ($app) {
$app['session']->start();
if (null === $user = $app['session']->get('user')) { if (null === $user = $app['session']->get('user')) {
return $app->redirect('/login'); return $app->redirect('/login');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment