The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
This isn't a problem, it's more of a question....
My class is located in a separate file called "clsGenFunctions", OK?
I have made one function that unsets some session variables, and this function sits within the class.
function unsetit() {
unset($_SESSION['title']);
unset($_SESSION['intro']);
unset($_SESSION['item']);
unset($_SESSION['product']);
unset($_SESSION['imgchecked']);
unset($_SESSION['insuranceopt']);
unset($_SESSION['feedback']);
unset($_SESSION['payment']);
unset($_SESSION['keyfeaturearray']);
}
OK, with me so far?
Seeing as this function is in a separate file to where it will be called, will it unset those session variables?
I am calling it using this
session_start();
include "clsGenFunctions.php";
$func = &New genfunctions; //Create object called func
$func->unsetit();
Seeing as session_start has been initiated at the beginning, the session variables should be unset successfully shouldn't they?
Cheers for any replies.
This isn't a problem, it's more of a question....
My class is located in a separate file called "clsGenFunctions", OK?
I have made one function that unsets some session variables, and this function sits within the class.
function unsetit() {
unset($_SESSION['title']);
unset($_SESSION['intro']);
unset($_SESSION['item']);
unset($_SESSION['product']);
unset($_SESSION['imgchecked']);
unset($_SESSION['insuranceopt']);
unset($_SESSION['feedback']);
unset($_SESSION['payment']);
unset($_SESSION['keyfeaturearray']);
}
OK, with me so far?
Seeing as this function is in a separate file to where it will be called, will it unset those session variables?
I am calling it using this
session_start();
include "clsGenFunctions.php";
$func = &New genfunctions; //Create object called func
$func->unsetit();
Seeing as session_start has been initiated at the beginning, the session variables should be unset successfully shouldn't they?
Cheers for any replies.
> Seeing as session_start has been initiated at the beginning, the
> session variables should be unset successfully shouldn't they?
Yes it will be.
$_SESSION is a superglobal, as such its visible everywhere within the current execution of your program.
> Cheers for any replies.
Shucks, really there's no need.
(With a different function)
function goto($loc) {
echo "";
}
Basically just takes the user to another page.
Can't seem to use it though, upon calling it with
$func->goto('design.php');
I just get the error: -
Fatal error: Call to a member function on a non-object in /var/www/localhost/htdocs/project/transaction.php on line 107
Any ideas?
EDIT: Managed to fix this!
I did it by making a new object. It seems that calling objects from within a function doesn't work without making a new one!
Anyway, managed to sort this again without even having to use a new object! Hurrah!
Problem, how do I pass 'objects' between pages?
Example:
class object {
var $objectproperty1;
var $objectproperty2;
function objectmethod() {
//code goes here
}
}
As you know, the above class defines an object, correct?
$a = new object;
$a->objectproperty1="chickens";
$a->objectproperty2="pies";
?>
How would I send the object "$a" to another page?
Now sure if I'm making myself clear.
Cheers for any help.
> Problem, how do I pass 'objects' between pages?
>
What you want to be looking at is http://uk2.php.net/serialize
Serialize your object, pass the string between pages as you like, by DB, sessions, cookies etc. and then unserialize in the new page.
include 'class_definitions.php'; //or whatever
session_start();
$myobect = $_SESSION['myobject']; //etc.