variable transport between pages, php

Asked

Viewed 47 times

-1

I have a login page where after the user and password entry he is redirected to a new page.

How can I store this user’s data and make it available on the next pages?

  • There are several ways to search for Sesssions.

1 answer

1


One of the ways to do this is by using sessions. You need to place session_start() at the beginning of each page where you will activate the session. Here’s a simple example:

Home page

<?php
session_start();
if (isset($_POST["email"])){
	$_SESSION["email"] = $_POST["email"];
	header("Location: minha_pagina.php");
	exit();
}
?>

Next page:

<?php
session_start();
if (isset($_SESSION["email"])){
	echo $_SESSION["email"];
}
?>

Here is more information?

https://medium.com/weyes/trabando-e-manipulando-sess%C3%A3o-no-php-ece2d9bf9e31

  • Bins, guy gave it right. thank you very much ! : D

Browser other questions tagged

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