0

I have a simple shopping cart system , how to list all the registered session as shown below:

<?php
if(isset($_SESSION['prod'][$_GET['id']])){
// How to list all $_SESSION['prod']['variable_here'] ?;
}
?>
Haren Sarma
  • 2,267
  • 6
  • 43
  • 72

4 Answers4

1

Use this,

As seesion is an array in php, you can php array functions for that.

if(!empty($_SESSION))
    echo "<pre>"; print_r($_SESSION);exit;
Anand Solanki
  • 3,419
  • 4
  • 16
  • 27
1

Not sure i understand exactly what are you asking. Anyway, you may try this to list all your sessions.

if(isset($_SESSION['prod'][$_GET['id']]))
{
    // suppose that session is an array
    foreach ($_SESSION['prod'] as $session)
    {
        echo $session; // supposedly you want to echo it? 
    }
}

Is this what you want to achieve? Regards Vladimir

Vladd
  • 124
  • 5
0
echo '<pre>';
print_r($_SESSION['prod']);
echo '</pre>';
Suman Biswas
  • 853
  • 10
  • 19
0

Try This :

    echo '<pre>';
    var_dump($_SESSION);
    echo '</pre>';
Ravi Delixan
  • 2,584
  • 1
  • 22
  • 31