Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * VIRTUALWARS
- *
- * Die lecker schmeckende Cookie Variation!
- *
- * Author: $ Blade83
- * Filename: cookie.class.php
- *
- */
- class cookie
- {
- protected
- $path,
- $del_time,
- $domain;
- public
- $coockie_contend,
- $cookie_time;
- public function __construct()
- {
- $this->path = "/"; # muss evt noch weiter ausgelesen werden
- $this->cookie_time = time() + (((60*60)*24)*14);
- $this->del_time = time() - (((60*60)*24)*14);
- $this->domain = $_SERVER['HTTP_HOST']; // test.de:100
- $splitdomain = explode(":", $this->domain);
- $this->domain = $splitdomain[0]; // test.de
- }
- public function get_cookie($name, $b64_decode=1)
- {
- if ($this->exists($name))
- {
- if($this->isempty($name) == FALSE)
- {
- if($b64_decode==1)
- $this->coockie_contend = base64_decode($_COOKIE[$name]);
- else
- $this->coockie_contend = $_COOKIE[$name];
- }
- }
- return (!empty($this->coockie_contend)) ? $this->coockie_contend: FALSE;
- }
- public function set_cookie($name, $value)
- {
- $value = base64_encode($value);
- if (!headers_sent())
- {
- $this->delete($name);
- #setcookie($name, $value, $this->cookie_time, $this->path, $this->domain);
- @setcookie($name, $value, $this->cookie_time, $this->path);
- }
- }
- /*public function delete_login_cookies()
- { this method is only used by vw!
- $alle = array('pwd_lenghtco','savecookie','userco','pwdco','acopendivids','acgroupswithpersist');
- for ($x=0; $x < count($alle); $x++)
- {
- $k = $this->delete($alle[$x]);
- }
- }*/
- public function delete($name)
- {
- $return = FALSE;
- if (!headers_sent())
- {
- if ($this->exists($name))
- {
- #@setcookie($name, "", $this->del_time, $this->path, $this->domain);
- @setcookie($name, "", $this->del_time, $this->path);
- $return = TRUE;
- }
- }
- return $return;
- }
- public function exists($name)
- {
- return (isset($_COOKIE[$name])) ? TRUE : FALSE;
- }
- public function isempty($name)
- {
- return (empty($_COOKIE[$name])) ? TRUE : FALSE;
- }
- }
- // Usage of this Class
- $cookie = new cookie(); // create instance
- $cookie->set_cookie('the_name_of_the_cookie', 'value_that_stored_in_cookie'); // this is a void method!
- $value = $cookie->get_cookie('the_name_of_the_cookie'); // Returns the Value from the Cookie
- $cookie->delete('the_name_of_the_cookie'); // Returns bool
- $cookie->exists('the_name_of_the_cookie'); // Returns bool
- ?>
- Thats it! Have a nice day!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement