开发者

problem with cookies in php

sorry i changed my question.

if( isset($_COOKIE["user"] ) )
    {
        /...
    }
    else
    {


        setcoo开发者_如何学Ckie("user","",time()+ 3600);

    }
    if( isset($_COOKIE["user"] ) )
    {
        echo "the cookie is set correct";//line 10
    }

in this code line 10 must execute but it doesn't execute why?


You write a cookie named user, but access in the other script a cookie named admin.

PHP's message is correct, since $_COOKIE does not contain a value for admin.

To learn, what's inside of $_COOKIE in the second script, perform this

print_r( $_COOKIE );

instead of echo().


you do realise that you are saying that the cookie will expire in 20 seconds.... the PHP Manual on Cookies might help you a little better. Edit: Now that you have updated your post, it seems that the main issue is that you have never declared $_COOKIE["admin"]

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜