Jump to content


Photo

sessions ending abruptly why?!?!?!


  • Please log in to reply
7 replies to this topic

#1 tiki

tiki
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts

Posted 19 June 2006 - 12:53 AM

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

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 19 June 2006 - 01:52 AM

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).
~ D Kuang

#3 tiki

tiki
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts

Posted 19 June 2006 - 03:42 AM

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;

#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 19 June 2006 - 05:04 AM

[!--quoteo(post=385509:date=Jun 18 2006, 08:42 PM:name=tiki)--][div class=\'quotetop\']QUOTE(tiki @ Jun 18 2006, 08:42 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]$_SESSION["cart"] = new Cart;
[/quote]
What is line 9 then?
~ D Kuang

#5 tiki

tiki
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts

Posted 19 June 2006 - 05:17 AM

[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.
$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; } ?>


#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 June 2006 - 05:46 AM

a href="browse/">Browse</a>


wrong { link }?


.php

wtf
the link missing exstention .php
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 tiki

tiki
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts

Posted 19 June 2006 - 05:48 AM

Wtf are u talking about?

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 June 2006 - 06:00 AM

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

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users