Jump to content


Photo

Session, Objects and Errors :0(


  • Please log in to reply
3 replies to this topic

#1 smileyriley21

smileyriley21
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 13 March 2006 - 05:58 PM

Hi,

I am experiencing an intermittant error "Call to a member funtion on a non object" using php objects as session variables.

My program structure stores the customer object as session variables. For instance, when a customer logs in I generate a customer object and store this as their session variable (with name, email etc etc). This gives me easy access to the information I need, when I need it.

Every now and then the error "Call to a member function on a non object" occurs. However, this is intermittant and does not follow any pattern.

I have experience this error when a customer continually refreshes the page. In this instance the session var is lost and therefore the object error occurs.

Here is an example..

$cust= unserialize($_SESSION['cust']);
$cust->doSomthing();
$cust= serialize($cust);

If the client refreshes the page whilst the function doSomthing() is called, the session var is lost.


Really, I need some advise on this? How can I ensure the session variable is not lost?

Many thanks, in advance

Dak


#2 redarrow

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

Posted 14 March 2006 - 09:00 AM


you must put session start at the top of the page to hold the varables on all pages.

<? session_start();
?>


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

#3 smileyriley21

smileyriley21
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 March 2006 - 09:03 AM

[!--quoteo(post=354810:date=Mar 14 2006, 04:00 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 14 2006, 04:00 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
you must put session start at the top of the page to hold the varables on all pages.

<? session_start();
?>

[/quote]

I do have this on each page, the problem only occurs every now and then..


regards

#4 redarrow

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

Posted 14 March 2006 - 09:19 AM

[!--quoteo(post=354813:date=Mar 14 2006, 09:03 AM:name=smileyriley21)--][div class=\'quotetop\']QUOTE(smileyriley21 @ Mar 14 2006, 09:03 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I do have this on each page, the problem only occurs every now and then..
regards
[/quote]

this is for object and varables php 5

[a href=\"http://uk2.php.net/zend-engine-2.php\" target=\"_blank\"]http://uk2.php.net/zend-engine-2.php[/a]

this is for object and varables php 4

[a href=\"http://uk.php.net/oop\" target=\"_blank\"]http://uk.php.net/oop[/a]


The links will help check your coding ok
good luck.
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