I suddenly found that the setcookie of php could not work, and it took almost an hour. Part of the index code: {code...} setc. php all code: {code...} is mainly a logon function, but setcookie is always invalid. The chromeurl column shows a user's cooki...
I suddenly found that the setcookie of php could not work, and it took almost an hour.
IndexSome code:
......《script》 function login(){ var a=$("#uname").val(); var b=$("#up").val(); var c=$("#yzm").val(); $.ajax({ method: "post", url: "setc.php", data: {uname: a, up: b, yzm: c}, success: function (msg) { alert(msg); }, complete: function (XHR, TS) { XHR = null } }); }《script》
......
Setc. phpAll code:
It is mainly a logon function, but setcookie is always invalid.
In the chrome url bar, you can see a user's cookie. val is also correct, that is, there is no refresh, and I don't know why.
This strange cookie is not found in the Development workbench.
There is a cookie here, but there will be no refresh.
Cookie not found here
I have changed ie and ff, and they are all the same results. Ask the experts for answers.
Reply content:I suddenly found that the setcookie of php could not work, and it took almost an hour.
IndexSome code:
......《script》 function login(){ var a=$("#uname").val(); var b=$("#up").val(); var c=$("#yzm").val(); $.ajax({ method: "post", url: "setc.php", data: {uname: a, up: b, yzm: c}, success: function (msg) { alert(msg); }, complete: function (XHR, TS) { XHR = null } }); }《script》
......
Setc. phpAll code:
It is mainly a logon function, but setcookie is always invalid.
In the chrome url bar, you can see a user's cookie. val is also correct, that is, there is no refresh, and I don't know why.
This strange cookie is not found in the Development workbench.
There is a cookie here, but there will be no refresh.
Cookie not found here
I have changed ie and ff, and they are all the same results. Ask the experts for answers.
Setcookie parameter settings are incomplete, reference http://php.net/manual/zh/function.setcookie.php
setcookie ( string $name [, string $value = "" [, int $expire = 0 [, string $path = "" [, string $domain = "" [, bool $secure = false [, bool $httponly = false ]]]]]] )
If path is not set for the third parameter, it is valid in the current path where setcookie is located by default, that is, the cookie you set is only valid under/tpok/login in the logon path, the cookie cannot be found after the page jumps.
setcookie("user", $cookie, strtotime( '+7 days' ), "domain or path");
Set the path/
If no path is set for setcookie, the default path is the path of the current page. The page in the parent path cannot be accessed.