Jump to content


Photo

Call variable stored in session inside a class


  • Please log in to reply
1 reply to this topic

#1 turner2000

turner2000
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 17 September 2006 - 07:46 PM

Hi,

Sorry my PHP skills are very limited but I have tried for a while with this problem and haven't suceeded so I'm hoping someone can help me (if I can explain my problem in words that make sense  :-\ ).

Inside a function I have created a variable and saved it to the session ID using the following code:

$_SESSION['current_price'] = $stripped3;
where $stripped3 is a variable that I've stripped of tags and trimmed.

When I call that variable on another page on the site that doesn't include the function using the echo function it displays correctly.

If I try and call that variable inside a class the variable has a value of 0. Below is the code I am using to try and compare 2 variables:

if ($products_ship_price > $current_price)
$this->shiptotal = ($products_ship_price);
else
$this->shiptotal = ($current_price);

How do I call the variable $current_price from a function and use it in this class?

I hope this makes sense.

Thanks in advance!

#2 turner2000

turner2000
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 17 September 2006 - 07:53 PM

Ok solved my own problem 5 mins after I posted this even though I've spent hours trying before!

All I had to do was reference the variable with:

$_SESSION['$current_price']

Probably an incorrect way of doing things but it works! Yay.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users