Phpcookie class (namespace used)-php Tutorial

Source: Internet
Author: User
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) ;}}}?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.