-3

I want to print a array on a other page with sessions but it is not working

<?php
session_start();
$aLijst = array(1,22,55,66,99, 234,9);
$_SESSION['getallen'] = $aLijst;
?>

The code where i want to print it

<?php
session_start();
$array = $_SESSION['getallen'];
echo $array;
?>

Im getting a undefined index error

  • try print $_SESSION first – Sonu Bamniya Jun 16 '16 at 10:37
  • Your code works fine. From which files is this code taken? Where in them this code is included? – Yury Fedorov Jun 16 '16 at 10:40
  • 3
    Possible duplicate of [How to use store and use session variables across pages?](http://stackoverflow.com/questions/5489365/how-to-use-store-and-use-session-variables-across-pages) Also [this](http://stackoverflow.com/questions/18731693/undefined-index-with-php-sessions) – Ani Menon Jun 16 '16 at 10:41

1 Answers1

-1

Use print_r() instead of echo because to print array you need to use print_r()

<?php
session_start();
$array = $_SESSION['getallen'];
print '<pre>';print_r($array);
?>
Dhara Parmar
  • 8,021
  • 1
  • 16
  • 27