Home > Backend Development > PHP Tutorial > 满足来自site 和cookie为空 两个条件 才赋予新cookie

满足来自site 和cookie为空 两个条件 才赋予新cookie

WBOY
Release: 2016-06-23 13:51:30
Original
824 people have browsed it

<%If Request.Cookies("xld") = "" And instr(Request.ServerVariables("HTTP_REFERER"),"site")>0 Then Response.Cookies("xld") = "xx" Response.Cookies("xld").Expires=dateadd("H",12,now()) Response.Write "欢迎你新来的" Else Response.Write "你已经来过了" End If%>
Copy after login

上边是ASP版本 由于服务器更换使用PHP 求解怎么写?


回复讨论(解决方案)

直译就可以

<?phpif($_COOKIE["xld"] == "" && strchr($_SERVER["HTTP_REFERER"], "site") !== false) {  setcookie("xld", "xx", strtotime('+12 hour'));  echo "欢迎你新来的";}else {    echo "你已经来过了";}?>
Copy after login

 echo "欢迎你新来的";
如果把其中的内容 换车 js代码 可以么

可以,你要什么样的?

 echo ’<script>alert("欢迎你新来的");</script>';

嗯 就是这种 谢谢版主了 结贴

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template