Blog

22 de June de 2023

$_SESSION

$_SESSION

With sessions we managed to have values in variables mesmo após a mudança de uma página para a outra ou atualização. Muito útil em páginas de login, carrinho de compras, identificar página atual e etc.

For the page use the session, at the beginning of each php file it is necessary to include the code:

<?php session_start(); ?>

We can check to see if it has already been started, if not, start:

  <?php
     // Verifica se NÃO existe a session
     if ( !isset( $_SESSION ) ){
         // Inicia a session
         session_start();
     }
  ?>

After that, we can use the variable $_SESSION in vector form, as in the example below:

    To use this variable, we can call it with echo:
    <?php
	echo $_SESSION['nome'];
    ?>
Share:
Others

Tips

Pulsar

Pulse

View more

Forçar o HTTPS

Force HTTPS

View more

Publicando o projeto React

Publicando o projeto React

View more