0

How to do something like this with cookies?

If a cookie exists, redirect user to a last used URL on a site or a homepage.

If not, create a cookie + redirect to specific page with registration form.

Can you check if this php-code is doing this as defined above?

<?php
if(!isset($_COOKIE['firsttime'])) {
?>
<meta http-equiv="refresh" content="0; url=http://example.com/">
<?php
} else {
setcookie('firsttime',time() + (86400 * 7));
?>
<meta http-equiv="refresh" content="0; url=http://example.com/"> // redirecrting to registratio form
<?php
}
?>
user3666197
  • 1
  • 6
  • 50
  • 92

1 Answers1

0

You should consider to use a php request rather than an meta tag because its more seamless for the end use. Check out this Thread: https://stackoverflow.com/a/768472/4043299

If you want more then user redircetion e.g. store login of user you should use PHP Sessions. With PHP Sessions you can safely storage data which is assigned to the users active ssesion.

Community
  • 1
  • 1
Laurenz
  • 51
  • 2