My file layout is as follows:
Index.php: (URL = domain/index.php)
<?php
session_start();
?>
<!-- BUNCH OF HTML -->
<?php
if($_GET['page'] == 'portfolio')
include('pages/portfolio.php');
?>
<!-- BUNCH OF HTML -->
Portfolio.php: (URL = domain/index.php?page=portfolio)
session_start();
if($_GET['view'] == 0){ // URL would be domain/index.php?page=portfolio&view=0
$_SESSION['catImages'] = array();
$_SESSION['catImages'][0] = "TEST";
} else { // URL would be domain/index.php?page=portfolio&view=#
echo $_SESSION['catImages'][0];
}
In my script, I am including portfolio.php into index.php. When user is on domain/.../?view=0 .. it should create a new session array variable and set its first element to TEST. When the user is on any other page, domain/.../?view=# .. it should output the value.
For some reason, it acts like the session variable was not created.
My current output: (domain/index.php?page=portfolio&view=#)
ERROR: NULL VARIABLE
My expected output: (domain/index.php?page=portfolio&view=#)
TEST
And yes, obviously the user first goes to view=0 by default and then clicks on an item which takes him/her to view=# ... so it should create session variable at view=0 and carry it on to view=# but it doesn't do that.
Thank you for all the help in advance.