First do not use $_COOKIE
it is not secure. related link
As you said, you are creating an independent page.
The first thing you have to keep in mind is:
Nothing you have in the other can be availed.
What does it say? Simple, it would be the same as starting something from scratch.
No constant, variable, class, or method of the previous location is known. If it exists, it is by mere coincidence, or because you have the same base project.
That way you have to think:
What resources do I have for these applications to communicate?
Some are JSON
, cookie
, sessão
, Arquivo Texto
.
In your case the ideal would be session, since it is a communication of independent pages on the same server.
To do this is simple, you can test with two same files.
file1.php
session_start();
$_SESSION['name'] = 'Guilherme Lautert';
file2.php
session_start();
echo isset($_SESSION['name'])?$_SESSION['name']:'Nome não definido';
Explanation
- In file1.php I sent the session a "key"
name
with a value.
- Note that in file2.php I am checking (
isset
) if there is a "key" name
in the session, this is either saying that it exists so I would have to handle it it does not exist.
Addendum
- Remember that session is the same as
$_GLOBAL
so if you change something in session it will be changing at all.