Cookies in WeChat built-in browsers are strange.

Source: Internet
Author: User
The cookie in the built-in browser is very strange. This is the code for setting and deleting the COOKIE {code ...} in a common browser, there is no problem at all. However, after you open this website, you can log on to the website. However, you cannot exit the website and cannot delete cookies... it's still time-based ,... the cookie in the built-in browser is very strange.
This is the code for setting and deleting cookies.

function set_cookie($var ,$value = '' ,$expire = 0){$path = '/';$domain = 'aaa.com';$auth = 'sadfsadfasdf';if($value!='') $value = _myencrypt($value ,$auth);$var = '__abc_'.$var;if($expire==0){    $expire = 0;}else if($expire > 0){    $expire = __TIME__ + (86400*$expire);}else{    $expire = $expire * 86400;}setcookie($var ,$value ,$expire ,$path,$domain);unset($var ,$expire ,$path ,$domain);}function delete_cookie($var){$path = '/';$domain = 'aaa.com';$expire = __TIME__ - 2592000;if(is_array($var)){    foreach($var as $val){        $var = '__abc_'.$val;        setcookie($var ,'' ,$expire , $path,$domain);    }}else{    setcookie('__abc_'.$var ,'' ,$expire , $path,$domain);}unset($path ,$expire ,$domain);}

In a normal browser, there is no problem at all.

However, after you open the website, you can log on without any problems, but you cannot log out. You cannot delete cookies all the time...

It's still time-based. I remember yesterday...

Neither IOS nor android

Reply content:

The cookie in the built-in browser is very strange.
This is the code for setting and deleting cookies.

function set_cookie($var ,$value = '' ,$expire = 0){$path = '/';$domain = 'aaa.com';$auth = 'sadfsadfasdf';if($value!='') $value = _myencrypt($value ,$auth);$var = '__abc_'.$var;if($expire==0){    $expire = 0;}else if($expire > 0){    $expire = __TIME__ + (86400*$expire);}else{    $expire = $expire * 86400;}setcookie($var ,$value ,$expire ,$path,$domain);unset($var ,$expire ,$path ,$domain);}function delete_cookie($var){$path = '/';$domain = 'aaa.com';$expire = __TIME__ - 2592000;if(is_array($var)){    foreach($var as $val){        $var = '__abc_'.$val;        setcookie($var ,'' ,$expire , $path,$domain);    }}else{    setcookie('__abc_'.$var ,'' ,$expire , $path,$domain);}unset($path ,$expire ,$domain);}

In a normal browser, there is no problem at all.

However, after you open the website, you can log on without any problems, but you cannot log out. You cannot delete cookies all the time...

It's still time-based. I remember yesterday...

Neither IOS nor android

The cookie in is not persistent. According to my test, sometimes it is disabled and then disabled. The specific time saved in Android and IOS may be different.

I tried to use cookies to identify the only user before, but I found that I could not. But there is no service number for Oauth authorization, which is really a headache for a while. Later I found this and solved my problem:
The door api: http://wgate.gaitianxia.com/

I also encountered the same problem, that is, the Cookie cannot be deleted, Which is annoying!
But now I find that my mobile phone will be like this, and others will not. My mobile phone parameters:
LT22i
Android 4.1.2 (kernel 3.0.8 +)
Version 6.2.4

In addition, the cookie can be repeated. When js modifies the cookie value, the original cookie value will also be valid. After alert, it will display "cityid = 3; cityid = 13 ;", so the background still obtains cityid = 3, which is too strange. all other browsers are normal.

function delCookie(name){    document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:01 GMT";}

This method can be used to delete cookies normally

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.