1.0.3 Session variables is not removed from memory

Discussion in 'General Support' started by Guest, Apr 29, 2012.

  1. Guest

    Guest Guest

    Last edited by a moderator: May 4, 2012
  2. interdummy

    interdummy New Member

    Joined:
    Apr 24, 2012
    Messages:
    28
    Likes Received:
    1
    Sorry, to clarify this issue -

    $_SESSION['SELL_array'] means to put your SELL_action, SELL_payment etc into a single array like so:

    $_SESSION['SELL_array'] = array(
    'payment' => 'etc',
    'action' => 'etc'
    );

    Then, you can simply unset them all by unsetting the entire array. This also allows you to better manage the entire data for an auction, serialize that data between requests, and easily store it for later. It is better practice.

    Not just that, because when you delete you use $_SESSION['blah'] = ''; you're control structures are messy. It should be:

    if(isset($_SESSION['SELL_array']['action']))

    not:

    if(!empty($_SESSION['SELL_action']))

    You can also move all this into objects and make it even more manageable.

    With a well designed object, this could turn into:

    $auction->loadData($_SESSION['SELL_array']);

    if($auction->getPayment())

    This then gives you the opportunity to reuse entire blocks of code, and will only make it more easier on yourselves, the developers, to further expand the script.
     
    Last edited: Apr 29, 2012
  3. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    1,871
    Likes Received:
    321
    Hi,
    If you look closely it is not unsetting anything apart from the first line unset($_SESSION['UPLOADED_PICTURES_SIZE']);
    All the rest are actually setting the variables, preparing them for future use.
     
  4. interdummy

    interdummy New Member

    Joined:
    Apr 24, 2012
    Messages:
    28
    Likes Received:
    1
    There is no need to prepare them for future use. Regardless of whether you prepare or not, storing each variable in a separate session variable is a waste when they can all be contained within a single array.
     
  5. carls1976

    carls1976 New Member

    Joined:
    Apr 19, 2012
    Messages:
    44
    Likes Received:
    1
    so if im understanding you correctly you are saying replace all that with this
    PHP:
    $_SESSION['SELL_array'] = array(
    'payment' => '',
    'action' => '',
    'starts' => '',
    'UPLOADED_PICTURES' => array(),
    'with_reserve' =>'',
    'reserve_price' =>'',
    'minimum_bid' => '',
    'file_uploaded' => '',
    'title'=> '',
    'subtitle' => '',
    'description' => '',
    'pict_url' => '',
    'pict_url_temp' => '',
    'atype' => '',
    'iquantity' =>'',
    'with_buy_now' => '',
    'buy_now_price' => '',
    'duration' => '',
    'relist' => '',
    'increments' => '',
    'customincrement' => 0,
    'shipping' => '',
    'shipping_terms' => '',
    'payment' => '',
    'international' => '',
    'buy_now_only' => '',
    'action' => '',
    'shipping_cost' => 0,
    'is_bold' => 'n',
    'is_highlighted' => 'n',
    'is_featured' => 'n',
    'start_now' => '1'
    );
     
    Last edited: May 3, 2012
  6. Guest

    Guest Guest

    NO i would not use this code.
     
  7. carls1976

    carls1976 New Member

    Joined:
    Apr 19, 2012
    Messages:
    44
    Likes Received:
    1
    you mind explaining your reply a bit
     
  8. nay27uk

    nay27uk Super Moderator Staff Member

    Joined:
    Nov 24, 2009
    Messages:
    4,037
    Likes Received:
    282
    what he is saying is that in order to use that code you would also have to rewrite the rest of webid. Read the original thread he referes to in in greay text above
     
  9. carls1976

    carls1976 New Member

    Joined:
    Apr 19, 2012
    Messages:
    44
    Likes Received:
    1
    maybe im missing something but from what i can see is all you are doing is using a array to store all the session variables instead of having loads of seperate sessions why would this mean you would have to rewrite the whole script
     
  10. nay27uk

    nay27uk Super Moderator Staff Member

    Joined:
    Nov 24, 2009
    Messages:
    4,037
    Likes Received:
    282
    Dont know mate but thats what the bloke that made the original post said needs doing.
    I supose if your confident enough that you could use it then why not use it, think dahl was refering to himself and folk like me that dont know how to code.
     
    Last edited: May 4, 2012

Share This Page