I’m building a site that features an extremely simple shopping cart. I want to avoid using Simple Commerce or any other plugin because there is no checkout or login process; the items in the cart just need to be saved as the person browses through the site.
I know how I would handle this with PHP sessions, but I know EE conflicts with those out of the box. I looked into the Session Variables plugin, but that doesn’t support arrays.
So what would be the recommended way of accomplishing this simple cart?
I know how I would handle this with PHP sessions, but I know EE conflicts with those out of the box.
Can you clarify this? I have used native PHP sessions in EE 1 and EE2 many times.
if (session_id() == '')
{
session_start();
}
$_SESSION['my_array'] = array(
'index' => 'value',
};You’re right, I totally forgot to include session_start(). But, now I’m having trouble passing the information between all my various templates.
I’ve got index.html which has {embed="core/.header"} and {embed="core/.footer"}. In header.html I’m accessing $_SESSION and attempting to put it into a variable. Unfortunately footer.html doesn’t see any of that.
Here’s the code in header:
$string = array();
foreach($_SESSION['quote']['bottles'] as $key[0]){
$string[] = $key[0][0];
}
$string = implode("|", $string);
$EE->session->cache['string'] = $string;Here’s the code in footer:
<? echo $string; ?>Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.