向首次访问者显示欢迎信息 [英] Display welcome message to first-time visitors

查看:26
本文介绍了向首次访问者显示欢迎信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在寻找一种简单的方式来向我网站上的首次访问者显示欢迎信息.最好的方法是什么?

Looking for a simple way to show a welcome message to first time visitors on my website. What's the best approach?

推荐答案

使用 cookie:

if (empty($_COOKIE['first_time'])) {
    show_welcome_message();
    setcookie("first_time", 1, time()+157680000);  /* expire in 5 years */
}

当然,如果用户清除了他的 cookie,他会再次看到该消息.如果他不接受 cookie,他将一直看到该消息.

Of course, if the users clears his cookies, he'll see the message again. If he doesn't accept cookies, he'll see the message all the time.

这篇关于向首次访问者显示欢迎信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆