www.webdeveloper.com
Results 1 to 3 of 3

Thread: cant delete item from session

  1. #1
    Join Date
    Feb 2012
    Posts
    31

    Question cant delete item from session

    Hi...im trying to remove item from session but it doesnt delete!
    PHP Code:
    if(isset($_GET['action']))
    {
         
    $choice=$_GET['action'];
        
        if(
    $choice=='add')
        {
             
    $Pid=$_GET['id'];
            
    $_SESSION['baseket'][$Pid]++;
            
    header("Location:mobiles.php");
            
        }
            if(
    $choice=='remove')
        {
             
    $Pid=$_GET['id'];
            
    $_SESSION['baseket'][$Pid]--;
            
             if(isset(
    $_SESSION['basket'][$Pid])<=0
             {
                
    //echo "<script>alert('zero items!');</script>";
                    
    unset($_SESSION['basket'][$Pid]);
                
             }
             
        
            
        }
        
        if(
    $choice=='empty')
        {
            
            unset(
    $_SESSION['baseket']);
            
    header("Location:mobiles.php");
            
        }
        
    }

    ?> 

  2. #2
    Join Date
    Feb 2012
    Posts
    31
    help anyone plss

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,387
    Do a session_write_close() right before you do the header() redirect.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles