How can I set the path when setcookie does not set the expiration time?

Source: Internet
Author: User
How can I set the path when setcookie does not set the expiration time? How can I set the path when setcookie does not set the expiration time?

The following write methods do not take effect:

setcookie(mycookie,'11','','/');   setcookie(mycookie,'11',,'/');   setcookie(mycookie,'11','/');

But write it like this:

setcookie(mycookie,'11',time()+31104000,'/');

But I don't want to point to the expiration time. I want to delete the COOKIE as soon as I close the browser.

I did not know how to write this case after reading the online tutorials.
Who can help me? thank you!

Reply to discussion (solution)

Use session

I want to use cookies, right?

Or

setcookie("mycookie", '11');setcookie("mycookie", '11');

In this way, the directory cannot be specified.

setcookie('mycookie','11',0,'/');

Is it clear in the manual?
Because the expire parameter is an integer, it cannot be replaced by zero (0 ).

Thank you for your answers :)

The preceding figure shows how to set the expiration time for setcookie without setting the path? For more information, see The PHP Chinese website (www.php1.cn )!

Related articles:

PHP setcookie usage

The php setcookie function is invalid.

Cookie setting PHP setcookie setting Cookie usage and invalid settings

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.