Phpcookie class (namespace used)
Share a php cookie operation class and use the namespace in php. this is relatively novel. For more information, see. A php cookie operation class provides basic operation functions: Creating a cookie, setting the cookie expiration time, and canceling a cookie. Code:
Name = (string) $ name) {if (! Is_null ($ value) {$ this-> value = (string) $ value; $ this-> expire = $ expire; $ this-> path = $ path; $ this-> domain = $ domain; $ this-> secure = $ secure; $ this-> httponly = $ httponly ;} else {$ this-> value = $ this-> exists ()? $ _ COOKIE [$ this-> name]: '';}} else {throw new Exception (" invalid cookie name ");}} /*** check whether the cookie exists * @ return boolean */public function exists () {return isset ($ _ COOKIE [$ this-> name]);} /*** set cookie information through setcookie */public function save () {return setcookie ($ this-> name, $ this-> value, $ this-> expire, $ this-> path, $ this-> domain, $ this-> secure, $ this-> httponly);}/*** cancel cookie */public function delete () {retur N setcookie ($ this-> name, "", time ()-3600) ;}}}?> |