First don’t use $_COOKIE
he’s not safe. related link
Like you said, you’re creating an independent page.
The first thing you have to keep in mind is :
Nothing that can be taken advantage of.
What does that 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 basic design.
That way you have to think :
What means 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 the file1.php I sent the session a "key"
name
with a value.
- Note that in the file2.php I am checking out (
isset
) if there is a "key in the session" name
, That is to say that it exists so I would have to treat for if it does not exist.
Addendum
- Remember that session is the same thing as a
$_GLOBAL
then if you change something in the session you will be changing throughout.