Skip to content

Commit 351f6db

Browse files
committed
minor symfony#9112 Mentioned the TargetPathTrait utility (javiereguiluz)
This PR was merged into the 3.3 branch. Discussion ---------- Mentioned the TargetPathTrait utility Commits ------- 9a5f7a6 Mentioned the TargetPathTrait utility
2 parents b8d7a49 + 9a5f7a6 commit 351f6db

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

security/form_login.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,24 @@ are now fully customized:
430430
<input type="hidden" name="back_to" value="<?php echo $view['router']->path('forgot_password') ?>" />
431431
<input type="submit" name="login" />
432432
</form>
433+
434+
Redirecting to the Last Accessed Page with ``TargetPathTrait``
435+
--------------------------------------------------------------
436+
437+
The last request URI is stored in a session variable named
438+
``_security.<your providerKey>.target_path`` (e.g. ``_security.main.target_path``
439+
if the name of your firewall is ``main``). Most of the times you don't have to
440+
deal with this low level session variable. However, if you ever need to get or
441+
remove this variable, it's better to use the
442+
:class:`Symfony\\Component\\Security\\Http\\Util\\TargetPathTrait` utility::
443+
444+
// ...
445+
use Symfony\Component\Security\Http\Util\TargetPathTrait;
446+
447+
$targetPath = $this->getTargetPath($request->getSession(), $providerKey);
448+
449+
// equivalent to:
450+
// $targetPath = $request->getSession()->get('_security.'.$providerKey.'.target_path');
451+
452+
.. versionadded:: 3.1
453+
The ``TargetPathTrait`` was introduced in Symfony 3.1.

0 commit comments

Comments
 (0)