嘿,我对发布请求的设置会话有问题。例如,请求正常工作。我已经试图在发布请求后重定向,但这不起作用。有我的代码的部分;Silex - 不能使用发布请求上的会话
不工作:
$app->post(
'/localauth',
'UserController::serviceLoginAuth'
)
->after(
function() {
session_name('auth')
session_start();
}
);
只工作不重定向serviceLoginAuth:
// redirect to '/authsuccess'
$app->post('/localauth', 'UserController::serviceLoginAuth');
$app->get('/authsuccess', 'UserController::serviceLoginAuthSuccess');
我使用HTTP POST,但角码:
$http({
url: apiConst.apiurl+'/localauth',
method: "POST",
data: $.param({
login: user.login,
pass:user.pass
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}
}).then(function(response){
console.log(response);
$cookies.put('csrftoken',response.data.token);
}).catch(function(){
console.log(err);
});
感谢您的帮助!
您是否收到任何错误? – Andy
没有这个标题即时通讯http代码405和选项错误。但是这个头文件修复了这个错误,但是我不能在发布后发送会话。 –