Jump to content

Archived

This topic is now archived and is closed to further replies.

tiki

sessions ending abruptly why?!?!?!

Recommended Posts

I have a cart system that uses sessions to track all the items in the cart, and price etc. The cart system uses a global cart class to do all its functions, but whenever you add an item to the cart, it works correctly then the sessions get messed up, why?

Test it out here, and add the item, then browse around and it messes up!

[a href=\"http://www.mileswjohnson.com/clients/Cssbooth/browse/MJ0001GR/1/\" target=\"_blank\"]http://www.mileswjohnson.com/clients/Cssbo...wse/MJ0001GR/1/[/a]

The sessions are echoed at the top as so:

echo $_SESSION;
print_r $_SESSION;
print_r $_SESSION["cart"];

I get these errors mostly:
Fatal error: Call to a member function on a non-object in /home/mileswjo/public_html/clients/Cssbooth/viewcart.php on line 9

Share this post


Link to post
Share on other sites
To begin with, why are you echoing $_SESSION? You can't use echo with arrays - actually you can but it's not pretty.

Then, you don't need to print_r $_SESSION['cart'] if you already printed $_SESSION. And you must use parenthesis when calling functions:

print_r($_SESSION);

And anyway, your error shouldn't be caused by this, but as result of uninitialized class. (calling $class->method() for example).

Share this post


Link to post
Share on other sites
I know how to echo a session, and how to use parenthesis. Im doing that so I see if the session is set and updates itself.

I do start the class though.

// Start sessions
session_start();
header("Cache-control: private");
$_SESSION["cart"] = new Cart;

Share this post


Link to post
Share on other sites
[!--quoteo(post=385509:date=Jun 18 2006, 08:42 PM:name=tiki)--][div class=\'quotetop\']QUOTE(tiki @ Jun 18 2006, 08:42 PM) [snapback]385509[/snapback][/div][div class=\'quotemain\'][!--quotec--]$_SESSION["cart"] = new Cart;
[/quote]
What is line 9 then?

Share this post


Link to post
Share on other sites
[a href=\"http://www.mileswjohnson.com/clients/Cssbooth/cart/\" target=\"_blank\"]http://www.mileswjohnson.com/clients/Cssbooth/cart/[/a]

This is the error lines, starting at 32.
[code]
$empty = $_SESSION["cart"]->items(); ?>

<div class="half">
<? if ($empty == 0) { ?>

    <p class="title">Your cart is empty</p>
    <p><a href="browse/">Browse</a> our templates and add them to your cart!</p>
    
<? return false; } ?>
[/code]

Share this post


Link to post
Share on other sites
a href="browse/">Browse</a>


wrong { link }?


.php

wtf
the link missing exstention .php

Share this post


Link to post
Share on other sites
[!--quoteo(post=385537:date=Jun 19 2006, 05:48 AM:name=tiki)--][div class=\'quotetop\']QUOTE(tiki @ Jun 19 2006, 05:48 AM) [snapback]385537[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Wtf are u talking about?
[/quote]
post whole page

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.