0

So if I start a session on one page, then send information via $_SESSION should I put session_start() at the top of the new page?

For Example:

page1.php:

session_start();
# code makes $foo
$_SESSION["var"] = $foo;
header("LOCATION: page2.php");
die;

page2b.php:

$foo = $_SESSION["var"];
# code uses $foo somehow

Does page2.php need session_start.php at the beggining of it? Especially if the only way to access it was through a page that starts a session?

Mxt
  • 166
  • 2
  • 17
  • You need `session_start()` whenever you want to use session variables in that page, so yes – kero May 04 '14 at 22:37
  • possible duplicate of [PHP Pass variable to next page](http://stackoverflow.com/questions/871858/php-pass-variable-to-next-page) – Nick Maroulis May 04 '14 at 22:40
  • Okay thanks kingkero, I just wasn't clear and I couldn't find a direct answer to this question anywhere. Not really a duplicate, as that question is asking about sending variables with forms. – Mxt May 04 '14 at 22:58

1 Answers1

0

Yes... in every page you should start a session