Welcome Guest, Not a member yet? Register   Sign In
Elegant Solution for Array Session - Ecommerce Basket
#5

[eluser]Dave Stewart[/eluser]
Something I just thought of (but haven't production-tested) would be to assign values to one variable by assigning a more-easily named by-reference pointer to it:

Code:
// start session
    session_start();
    
// create a short-named by-reference pointer to the long-winded-variable-name
// (note the & in front of the variable name)
    $username = &$_SESSION['user']['name'];
    
// assign the value to the variable via the referenced pointer
    if(!isset($username)){
        $username = 'Dave';
        }

// check the session variable
    echo "<pre>";
    print_r($_SESSION);
    echo "</pre>";

Not sure if that helps your problem or not, but it was interesting to play with anyway.


Messages In This Thread
Elegant Solution for Array Session - Ecommerce Basket - by El Forum - 06-24-2008, 08:47 AM
Elegant Solution for Array Session - Ecommerce Basket - by El Forum - 06-24-2008, 09:44 AM
Elegant Solution for Array Session - Ecommerce Basket - by El Forum - 06-24-2008, 11:31 AM
Elegant Solution for Array Session - Ecommerce Basket - by El Forum - 06-24-2008, 11:53 AM
Elegant Solution for Array Session - Ecommerce Basket - by El Forum - 06-24-2008, 12:11 PM
Elegant Solution for Array Session - Ecommerce Basket - by El Forum - 06-24-2008, 03:42 PM
Elegant Solution for Array Session - Ecommerce Basket - by El Forum - 07-15-2008, 06:42 PM
Elegant Solution for Array Session - Ecommerce Basket - by El Forum - 07-16-2008, 12:19 PM
Elegant Solution for Array Session - Ecommerce Basket - by El Forum - 07-16-2008, 02:14 PM
Elegant Solution for Array Session - Ecommerce Basket - by El Forum - 07-16-2008, 07:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB