Link to home
Start Free TrialLog in
Avatar of jej07
jej07

asked on

Help avoiding duplicates when adding to PHP Session

When trying to add one or more arrays to my Session array, I run into a problem where the added array is duplicated on a page reload. I've tried a few different things to avoid this, but can not seem to find the solution.

Is it possible to somehow count how many times the page has been refreshed so that $discountedItems is only added once to the Session, regardless of how many times the page get's refreshed?

$discountedItems = array(
                    'name' => 'discount', 
                    'quantity' => '1', 
                    'price' => '-35.00',
                    );

array_push($_SESSION['items'],$discountedItems);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of teebon
teebon
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial