Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Session shopping basket suddenly not working

    Hi

    I have a site which uses a shopping basket stored in session variables. It has been working fine for a long time but has now just stopped working. I can't identify when it stopped working and I can't see what is wrong with it, other than that it just doesn't seem to be registering the session variables (maybe??!!). Session variables are working in other places on the site, like when logging in so perhaps that is a red herring.

    I did move the site to a new server but that was months ago. Having said that, I can't say if it was working after that as it is a customer's site and they have only just reported the problem.

    Anyway, the code is below - it probably won't mean much out of context but if anyone can see anything obvious, please let me know. I am getting no errors, just nothing in the shopping cart.

    PHP Code:
    if ($basket!=""){
           if (
    session_is_registered("ses_basket_items")){
            
    $basket_position_counter=0;
                       
    $ses_basket_name[]=$basket;
               
    $ses_basket_amount[]=1;
               
    $ses_basket_priceid[]=0;
               
    $ses_basket_size[]=0;
               
    $ses_basket_price[]=$price;
                
    $ses_basket_album[]=$album;
                          
    $ses_basket_id[]=$id;
               
    $ses_basket_items++;
            
        }else{
            
    $ses_basket_items=1;
            
    $ses_basket_name[0]=$basket;
            
    $ses_basket_amount[0]=1;
            
    $ses_basket_priceid[0]=0;
            
    $ses_basket_size[0]=0;
            
    $ses_basket_album[0]=$album;
            
    $ses_basket_price[0]=$price;
            
    $ses_basket_id[0]=$id;
            
    session_register("ses_basket_items");
            
    session_register("ses_basket_name");
            
    session_register("ses_basket_amount");
            
    session_register("ses_basket_priceid");
            
    session_register("ses_basket_size");
            
    session_register("ses_basket_price");
            
    session_register("ses_basket_album");
            
    session_register("ses_basket_id");
        }


  • #2
    New Coder
    Join Date
    Feb 2005
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have got it now to add something to the basket, but when I try to add another item or update the price etc, it looses everything in the basket??

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,151
    Thanks
    2
    Thanked 335 Times in 327 Posts
    Start by checking your error log and/or put the following in after your first opening <?php tag -
    PHP Code:
    ini_set ("display_errors""1");
    error_reporting(E_ALL); 
    Secondly, session_register, session_is_registered... are depreciated and only work when register_globals are on. It is highly likely that register_globals got turned off. Working code does not spontaneously stop working. It requires something to change either within the code or within the environment that the code is running.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

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