Laravel 4 Session Redirect URLs

Two handy methods to redirect a user to their intended URL on log in.

A short tip this time: while looking through the Laravel Routing code, I found a couple of undocumented methods that are extremely useful, especially if you're creating an auth system.

// Redirect the user to /log-in
// Also storing the current URL in the session
// This is generally placed in an auth filter

// Redirect the user back to the intended URL (stored in the session)
// Or redirect to /dashboard if no URL is stored
// This is generally placed just after a user has logged in

While they don't do much work (you could quite easily store the intended URL in the session yourself), it's a nice little shortcut.

They're pretty self explanatory, but if you want more information you can check them out on GitHub:

Want to let me know what you think of Laravel 4 Session Redirect URLs? Why not leave a comment, follow me on Twitter , or !


comments powered by Disqus