<?php
//Start your session.
session_start();
//Add a product ID to our cart session variable.
$_SESSION['cart'][] = 2787376;
//Dump it out for example purposes.
var_dump($_SESSION);
//how to access it
<?php
//Start your session.
session_start();
//Make sure that the session variable actually exists!
if(isset($_SESSION['cart'])){
//Loop through it like any other array.
foreach($_SESSION['cart'] as $productId){
//Print out the product ID.
echo $productId, '<br>';
}
}