0
$cookie_name = "login";
$cookie_value = "True";
setcookie($cookie_name, $cookie_value);
header("Location: http://Startseite.php");
exit;

#And this is on "Startseite.php"

if (isset($_COOKIE['login']))
   echo "login erfolgreich"

The Echo dont give a Result. This says that my cookie is not set.I tried it with more Values, but with the same result.

2 Answers2

0

You need to use if(isset($_COOKIE['login']) { and echo $_COOKIE['login'];. For more reference, take a look at: https://www.php.net/manual/en/function.setcookie.php

Hope this helps!

ItsGageH
  • 385
  • 1
  • 9
0

Have you ever tried this?

If you have human urls or subfolders (like www.domain.com/path1/path2/), then you must set cookie path to / to work for all paths, not just current one.

How can I set a cookie and then redirect in PHP?

Buu Pham
  • 131
  • 1
  • 4