开发者

Can cookies be sent on along with a HTTP 30x response?

I have a PHP login page with the following structure:

<?php
    // validate login
    // ...
    if (login_okay) {
        // save user and password as secure cookies cookies
        $time = time() + 3600;
        setcookie('user', $user, $time, null, null, true);
        setcookie('pass', $pass, $time, null, null, true);

        // redirect to main page
        header('HTTP/1.1 302 Found');
        header('Location: /mainpage');
    }
?>
<html>
<!-- ... -->

However, the next time I attempt to log in, the stored user ID and password are not displayed in the form. Why is that happening? Maybe cookies cannot sent along wi开发者_Python百科th an HTTP 30x response?


Cookies are allowed with 302 and this is a very common practice. There is likely something wrong with the code (which you didn't include here) for later reading from the cookies and displaying their values in the form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜