Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

session array

<?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>';
    }
}
Source by thisinterestsme.com #
 
PREVIOUS NEXT
Tagged: #session #array
ADD COMMENT
Topic
Name
1+9 =