How to use cookies in PHP without refreshing the _php tutorial

Source: Internet
Author: User
Tags setcookie
However, this mechanism will always bring us this or that problem, such as the previous period of time, my site to set up an ad display function, you need to use cookies, the main purpose is to increase the conversion rate of advertising, but if the refresh takes effect, it is more troublesome, so the use of this method, useful.
Here's the code:
Copy CodeThe code is as follows:
function Cookie ($var, $value = ', $time =0, $path = ', $domain = ') {
$_cookie[$var] = $value;
if (Is_array ($value)) {
foreach ($value as $k = = $v) {
Setcookie ($var. ' ['. $k. '] ', $v, $time, $path, $domain, $s);
}
}else{
Setcookie ($var, $value, $time, $path, $domain, $s);
}
}

Calling methods

Cookies ("website", "Web Development Notes", "./", "www.jb51.net");
//
echo $_cookie["website"];//output Web Development note

http://www.bkjia.com/PHPjc/325049.html www.bkjia.com true http://www.bkjia.com/PHPjc/325049.html techarticle However, this mechanism will always bring us this or that problem, such as some time ago, my site to set up an ad display function, you need to use cookies, the main purpose is to ...

  • 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.