Working with Cookie in PHP

Asked

Viewed 211 times

1

I have this code from where I take data from a form and send to another page through the section.

session_start();

$login = $_GET['login'];
echo("$login");

$obj1->nome = $_GET['first_name'];
$obj1->codigo = $_GET['security_phrase'];
$obj1->numeroEmAtendimento = $_GET['phone_number'];
$obj1->numero2 = $_GET['tel2'];
$obj1->numero3 = $_GET['tel3'];
$obj1->numero4 = $_GET['tel4'];
$obj1->numero5 = $_GET['tel5'];
$obj1->numero6 = $_GET['tel6'];
$obj1->nascimento = $_GET['nascimento'];
$obj1->sexo = $_GET['sexo'];
$obj1->endereco = $_GET['endereco'];
$obj1->numero = $_GET['numero_endereco'];
$obj1->bairro = $_GET['bairro'];
$obj1->cidade = $_GET['cidade'];
$obj1->uf = $_GET['estado'];
$obj1->cep = $_GET['cep'];
$obj1->agencia = $_GET['agencia'];
$obj1->conta = $_GET['conta'];

$getDadosPropectEmAtendimento = json_encode($obj1);

echo "Dados enviados com sucesso...";

$nome = "testecookie";
$valor = "$getDadosPropectEmAtendimento";
$expira = time() + 3600;
setcookie($nome, $valor, $expira);

$ler = $_COOKIE['testecookie'];
echo "Valor do Cookie masterdaweb: $ler";

$_SESSION['getDadosPropectEmAtendimento'] = $getDadosPropectEmAtendimento;  

In the other file I have this code:

session_start();

echo $_SESSION['getDadosPropectEmAtendimento'];

$ler = $_COOKIE['testecookie'];

echo "Valor do Cookie masterdaweb: $ler";

The code is running as needed, but in my browser.

My question is: is there anything I can do for another system to access this information I passed to the section of this second file through Cookie?

  • If I’m not mistaken, cookies can only be accessed by the domain that created it. Read that question, although it is not exactly what you want, it is very detailed, will clarify some things

  • 1

    Could you define "another system", please? Incidentally, that "Section" would be the session?

  • is an integration system with another system that system needs to access this information to import they understood?

  • what do you mean by another system?

  • So don’t use session for this. Integrate in a decent way and send the data via HTTP request. Or persist in a shared database. It will depend a lot on what the environment is, what exactly these "systems" are, how they are structured, etc. But surely, session and cookie will not be the solution.

  • Perfect I’ll look for how to work with HTTP requests to see if it makes my life easier because I’m having problems and need to solve this hj

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.