With $_GET
you will only have access to the variable, in this case with value 23
in service http://www.app.com.br?usuario=23
, because in http://www.app.com.br?usuario=24
you will no longer have your variable with 23
value, but yes 24
.
That said, to temporarily save a variable across your entire application, you should use session or < a href="http://www.w3schools.com/php/php_cookies.asp"> cookies .
In this case if you want to save the value $_GET['usuario']
in a session, you do (this is a very basic way):
<?php
session_start();
$_SESSION['usuario'] = $_GET['usuario'];
In which you will have access on all other pages, if you place them on top of them all session_start()
.
But this does not make much sense to me (so I realized), because if the user then goes to url http://www.app.com.br?usuario=24
, the variable $_SESSION['usuario']
will now have the value 24
.
My tip, if user 23
can not see http://www.app.com.br?usuario=24
is to save this id from login and check this page:
<?php
session_start();
if($_SESSION['usuario'] != $_GET['usuario']) {
header('Location: OUTRA_PAG.php');
die();
}