Forum Moderators: coopster
Fatal error: Call to undefined method stdClass::set() in /home/website/index.php on line 21
I understand from research that all classes are children of the stdclass, but little more about it.
i am creating my cookie object in the usual fashion and calling set on my cookie object in the usual fashion, but i do not understand why php is refering to stdclass instead of my cookie class and not finding my set method.
Any help would be grately appreciated.
Once again Thankyou.
Not quite sure what it is off the bat; looks like you are using an object for something you aren't suppose to be.
Sorry to be the bearer of bad news.
here is the source for 2 files
1.Single signon client code
2.cookie class
my apologies for posting so much code but i am unsure where the error is.
this is the single sign on client code i am using, this code code on the client server.
<?php
//client script
require_once 'Cookie.php';
require_once 'SingleSignOn.php';
require_once 'Exception.php';
require_once 'config.php';
require_once 'Authentication.php';
check_auth();
echo "client script";
function check_auth() {
try {
$cookie1 = new Cookie();
$cookie1->validate();
}
catch(AuthException $e) {
try {
$client = new SingleSignOn_Example();
//echo "client name".$client->client;
$client->process_auth_response($_GET['response']);
$cookie1->userid = $client->userid;
$cookie1->set();
}
catch(SignOnException $e) {
$client->originating_uri = $_SERVER['REQUEST_URI'];
$client->generate_auth_request();
// we have sent a 302 redirect by now, so we can stop all other work
exit;
}
}
}
?>
this is the cookie class
<?php
require_once 'SingleSignOn.php';
require_once 'Exception.php';
require_once 'config.php';
require_once 'Authentication.php';
class Cookie {
private $created;
private $userid;
private $version;
private $td;
private $cookie;
private $cypher = 'blowfish';
private $mode = 'cfb';
private $key = 'fortheforum';
private $cookiename = 'USERAUTH';
private $myversion = '1';
private $expiration = '600';
private $warning = '300';
private $glue = '¦';
public function __construct($userid = false) {
$this->td = mcrypt_module_open ($this->cypher, '', $this->mode, '');
if($userid) {
$this->userid = $userid;
return;
}
else {
if(array_key_exists($this->cookiename, $_COOKIE)) {
$buffer = $this->_unpackage($_COOKIE[$this->cookiename]);
}
else {
throw new AuthException("No Cookie");
}
}
}
public function set() {
$cookie = $this->_package();
setcookie($this->cookiename, $cookie, 0);
}
public function logout() {
setcookie($this->cookiename);
}
public function validate() {
if(!$this->version ¦¦!$this->created ¦¦!$this->userid) {
throw new AuthException("Malformed cookie");
}
if ($this->version!= $this->myversion) {
throw new AuthException("Version mismatch");
}
if (time() - $this->created > $this->expiration) {
throw new AuthException("Cookie expired");
} else if ( time() - $this->created > $this->resettime) {
$this->set();
}
}
private function _package() {
$parts = array($this->myversion, time(), $this->userid);
$cookie = implode($glue, $parts);
return $this->_encrypt($cookie);
}
private function _unpackage($cookie) {
$buffer = $this->_decrypt($cookie);
list($this->version, $this->created, $this->userid) = explode($this->glue, $buffer);
if($this->version!= $this->myversion ¦¦
!$this->created ¦¦
!$this->userid)
{
throw new AuthException();
}
}
private function _encrypt($plaintext) {
//$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
//mcrypt_generic_init ($this->td, $this->key, $iv);
//$crypttext = mcrypt_generic ($this->td, $plaintext);
//mcrypt_generic_deinit ($this->td);
//return $iv.$crypttext;
return $plaintext;
}
private function _decrypt($crypttext) {
//$ivsize = mcrypt_get_iv_size($this->td);
//$iv = substr($crypttext, 0, $ivsize);
//$crypttext = substr($crypttext, $ivsize);
//mcrypt_generic_init ($this->td, $this->key, $iv);
//$plaintext = mdecrypt_generic ($this->td, $crypttext);
//mcrypt_generic_deinit ($this->td);
//return $plaintext;
return $cryptext;
}
private function _reissue() {
$this->created = time();
}
}
/* vim: set ts=2 sts=2 ai bs=2 expandtab: */
?>
I'm sorry I cannot be of anymore help. Have a quick read through Troubleshooting 101 [webmasterworld.com] to see what steps you should do to discover your problem and find the solution.