简体   繁体   English

Laravel 4使用先前的POST数据重定向到预期的URL

[英]Laravel 4 redirect to intended URL with previous POST data

In Laravel 4 it is possible to redirect to an intended URL while using the withInput() method, which is a great feature. 在Laravel 4中,可以使用withInput()方法重定向到目标URL,这是一个很棒的功能。 However, I'm wondering if it's possible to do the following: 但是,我想知道是否可以执行以下操作:

I have a form that I want to show to all of my users (whether they're logged in or not). 我有一个要向所有用户显示的表单(无论他们是否登录)。 If they try to post this form when not logged in, they will be redirected to the site's login page. 如果他们尝试在未登录时发布此表单,则会将他们重定向到网站的登录页面。 After successfully logging in, is it possible to redirect the user to the intended URL and POST the information from the original form? 成功登录后,是否可以将用户重定向到预期的URL 以原始形式发布信息?

Another solution would be to send the POST data to the login form as you are doing now using the withInput() method and then add the captured values to hidden inputs within your login form. 另一个解决方案是像现在一样使用withInput()方法将POST数据发送到登录表单,然后将捕获的值添加到登录表单内的隐藏输入中。

If you didn't want the hidden inputs rendered unless the data existed, you could add them dynamically using JavaScript. 如果您不希望除非数据存在就呈现隐藏的输入,则可以使用JavaScript动态添加它们。

Since using withInput() just flashes it to your session, it might be possible to work with a Session::reflash(); 由于使用withInput()只会将其闪烁到您的会话中,因此可以使用Session::reflash(); or Session::keep(array('Form1Data', 'Form1DataToo')); Session::keep(array('Form1Data', 'Form1DataToo')); in your login page. 在您的登录页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM