Symfony2.3 - 如何在iframe中进行身份验证


Symfony2.3 - how to authenticate in iframe

我有一个带有iframe的外部页面,其中应该加载一个特定的Symfony页面。不幸的是,该页面需要登录,因此我尝试创建一个不可见的表单,其中包含_password和_username,该表单将提交到iframe作为目标:

<form target="theiframe" id="theiframe" name="frameform" method="post" action="http://someurl.com/login_check">
<input type="hidden" id="username" name="_username" placeholder="User" value="theusername" required="" autofocus="">
<input type="hidden" id="password" name="_password" placeholder="Passwort" value="thepassword" required="">
</form>
<iframe width="100%" height="500" frameborder="0" name="theiframe" id="theiframe" src=""></iframe>

但是出于某种原因,当我尝试此操作时,Symfony将我重定向到登录表单,并显示错误:

Your session has timed out, or you have disabled cookies.

一旦我重新加载页面,它就会突然起作用。这只是第一次尝试失败。

有没有办法解决这个问题?如何?

转到 external_page symfony2 中的 secure.yml。并添加这个:

secured_area:
    ...
    form_login:
        ...
        require_previous_session: false