Results 1 to 10 of 10
  1. #1
    Banned/Coder/Designer
    Join Date
    Dec 2009
    Posts
    1,349

    Exclamation Session variables is not removed from memory

    NOTE: not sure this is done right or if there is other places in webid it has to be done,
    this is part of comment to the will this script be completely rewritten from scratch?


    Removed! the code as some actual thinking this example was a mod.
    Last edited by Dahlsvarehus.com; 04-05-2012 at 08:00 AM.

  2. #2

    Default

    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 by interdummy; 29-04-2012 at 11:56 AM.

  3. #3
    Senior Member/Coder pani100's Avatar
    Join Date
    May 2011
    Location
    London
    Posts
    1,609

    Default

    Hi Dahlsvarehus.com,
    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. #4

    Default

    Quote Originally Posted by pani100 View Post
    Hi Dahlsvarehus.com,
    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.
    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. #5

    Default

    so if im understanding you correctly you are saying replace all that with this
    PHP Code:
    $_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 by carls1976; 03-05-2012 at 09:31 PM.

  6. #6
    Banned/Coder/Designer
    Join Date
    Dec 2009
    Posts
    1,349

    Default

    NO i would not use this code.

  7. #7

    Default

    you mind explaining your reply a bit

  8. #8
    Super Moderator/Coder/Designer nay27uk's Avatar
    Join Date
    Nov 2009
    Location
    Leicester, UK
    Posts
    3,609

    Default

    Quote Originally Posted by carls1976 View Post
    you mind explaining your reply a bit
    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. #9

    Default

    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. #10
    Super Moderator/Coder/Designer nay27uk's Avatar
    Join Date
    Nov 2009
    Location
    Leicester, UK
    Posts
    3,609

    Default

    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 by nay27uk; 04-05-2012 at 08:53 AM.

Bookmarks

Posting Permissions

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