Hi I have a php page that I want show it just one time per user.
I think this just might be possible with cookies,session-timeout or session-cookies.
But I'm not sure.
Thanks for your kindness :)
Hi I have a php page that I want show it just one time per user.
I think this just might be possible with cookies,session-timeout or session-cookies.
But I'm not sure.
Thanks for your kindness :)
you answered your own question - by setting a cookie.
// check if they've been here, if they haven't set
// a cookie for subsequent visits
if($_COOKIE['beenhere']) {
setcookie("beenhere", '1');
}
else {
// where you want them to go if they've seen this page
header('Location: http://www.example.com/');
For more information:
If you want a single user to -never- see the page again, you must set an expiration for the cookie (see linked page above) as closing the browser will eliminate the cookie as I've set it above.
To show a page once per-user-session you can try the following
//mypage.php
if(!isset($_SESSION['mypage_view'])
{
$_SESSION['mypage_view'] = 1;
} else {
//check if this is not the first time the page has been viewed
if(isset($_SESSION['mypage_view'])) {
//not first time redirect
header('location: google.com');
session_write_close();
exit();
}
}
You may also use sessions
if($_SESSION['sessioned_here'] == null) {
// just been on this page
} else {
// visited already. get out
}