Php-cookie-PHP cannot delete cookies

Source: Internet
Author: User
$ Cookie retention time $ falg user Unique Identifier $ name User name set cookie information function_setcookie ($ name, $ flag, $ time) {{ code ...}}? & Amp; gt; why cannot I delete IE and Firefox? Setcookie (& quot; username & quot;, & quot;, time ()-...

// $ Cookie retention time
// $ Falg user Unique Identifier
// $ Name Username
// Set cookie Information
Function _ setcookie ($ name, $ flag, $ time)
{

Switch ($ time) {case 0: setcookie ('username', $ name); setcookie ('userflag', $ flag); _ alert_location ('login successful ', 'index. php '); break; case 1: setcookie ('username', $ name, time () + 86400); setcookie ('userflag', $ flag, time () + 86400); _ alert_location ('logon successful ', 'index. php'); break; case 2: setcookie ('username', $ name, time () + 604800); setcookie ('userflag', $ flag, time () + 604800); _ alert_location ('logon successful ', 'index. php '); break ;}

}
?>

IE and Firefox cannot be deleted. Why?

Setcookie ("username", "", time ()-1 );
Setcookie ("userflag", "", time ()-1 );

This is not the case.

I have solved it ~ Is the path Problem
Setcookie ("username", "", time ()-1, '/My_Dome % 201.0 /');
It looks like this ~ But it is strange why '/My_Dome % 201.0/' must be added during local debugging. Isn't it? How can I modify the website after it is officially launched?

Even more depressing is that the path under Firefox and iE is different ~
Setcookie ("username", "", time ()-1, '/My_Dome % 201.0/'); // Delete method under Firefox
Setcookie ("userflag", "", time ()-1, '/My_Dome % 201.0 /');
Setcookie ("username", "", time ()-1, '/My_Dome % 8080'); // delete a cookie in IE
Setcookie ("userflag", "", time ()-1, '/My_Dome % 100 ');

How can I solve this problem ~

Reply content:

// $ Cookie retention time
// $ Falg user Unique Identifier
// $ Name Username
// Set cookie Information
Function _ setcookie ($ name, $ flag, $ time)
{

Switch ($ time) {case 0: setcookie ('username', $ name); setcookie ('userflag', $ flag); _ alert_location ('login successful ', 'index. php '); break; case 1: setcookie ('username', $ name, time () + 86400); setcookie ('userflag', $ flag, time () + 86400); _ alert_location ('logon successful ', 'index. php'); break; case 2: setcookie ('username', $ name, time () + 604800); setcookie ('userflag', $ flag, time () + 604800); _ alert_location ('logon successful ', 'index. php '); break ;}

}
?>

IE and Firefox cannot be deleted. Why?

Setcookie ("username", "", time ()-1 );
Setcookie ("userflag", "", time ()-1 );

This is not the case.

I have solved it ~ Is the path Problem
Setcookie ("username", "", time ()-1, '/My_Dome % 201.0 /');
It looks like this ~ But it is strange why '/My_Dome % 201.0/' must be added during local debugging. Isn't it? How can I modify the website after it is officially launched?

Even more depressing is that the path under Firefox and iE is different ~
Setcookie ("username", "", time ()-1, '/My_Dome % 201.0/'); // Delete method under Firefox
Setcookie ("userflag", "", time ()-1, '/My_Dome % 201.0 /');
Setcookie ("username", "", time ()-1, '/My_Dome % 8080'); // delete a cookie in IE
Setcookie ("userflag", "", time ()-1, '/My_Dome % 100 ');

How can I solve this problem ~

Check whether the path and domain are wrong.

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.