Jump to content

$_SESSION problem


robert_gsfame

Recommended Posts

I try to create add to carts, but i face this problem..below i attach the code

 

assume checkvalue= 6;8...then i explode the value using ";" as the separator and then i loop the value and check whether there is an old SESSION already...if not then i set the new one or else adding (+1) the new session array. besides i don't want the same record to be stored in $_SESSION array so i check it first

 

2 problems occured:

* When $_SESSION['basket'][0] not yet exist, i fail to create the new one

* i still can store the same record again and again although i have the old one

 

$checkvalue=$_GET['checkvalue'];

$explode=explode(";",$checkvalue);

$count=count($explode);

$countbasket=count($_SESSION['basket']);

for($i=0;$i<$count;$i++){

if(!isset($_SESSION['basket'][0])){

$x=0;}else{

$total=count($_SESSION['basket']);

$x=$total+1;}

$find=0;

for($a=0;$a<$countbasket;$a++){

if(base64_encode(urlencode($explode[$i]))==$_SESSION['basket'][$a]){

$find++;}}

if($find>0){

$_SESSION['basket'][$x]=base64_encode(urlencode($explode[$i]));}}

 

thanks for any helps

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.