js读取php生成的cookie
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<?php
setcookie(
"username"
,
"js读取php生成的cookie,成功"
);
setcookie(
"password"
,
"密码"
);
echo $_COOKIE[
'username'
];
?>
<script language=
"javascript"
>
function
readCookie(name){
var
nameEQ = name +
"="
;
var
ca = document.cookie.split(
';'
);
for
(
var
i=0;i < ca.length;i++){
var
c = ca[i];
while
(c.charAt(0)==
''
) c=c.substring(1,c.length);
//document.write(decodeURIComponent(c)+'<br>');
if
(c.indexOf(nameEQ)==0)
return
decodeURIComponent(c.substring(nameEQ.length,c.length));
【责任编辑:CSW8923】