0

I have this code below as as an example .. should I use session_start() again in all the included scripts if I already have it on top in the parent file ..

here's parent.php

<?php
session_start();
include 'child1.php';
include 'child2.php';

//
?>

do child1.php and child2.php need session_start() as well in order to use session variables in them or is the first session_start of the parent.php file enough for the include files to use session variables?

Stack Overflow
  • 247
  • 2
  • 5
  • 14

1 Answers1

2

No you only want session_start() called once.

Calling session_start() after the session was previously started will result in an error of level E_NOTICE. Also, the second session start will simply be ignored.

kero
  • 10,647
  • 5
  • 41
  • 51
jszobody
  • 28,495
  • 6
  • 61
  • 72