Deprecated: setcookie(): Passing null to parameter #5 ($domain) of type string is deprecated in woedpress and php version 8.2

huangapple go评论102阅读模式
英文:

Deprecated: setcookie(): Passing null to parameter #5 ($domain) of type string is deprecated in woedpress and php version 8.2

问题

Deprecated: setcookie(): Passing null to parameter #5 ($domain) of type string is deprecated on php version 8.2.

function qtranxf_setcookie_language($lang, $cookie_name, $cookie_path, $cookie_domain = NULL, $secure = false){
	qtranxf_dbg_log('qtranxf_setcookie_language: lang='.$lang.'; cookie_name='.$cookie_name.'; cookie_path='.$cookie_path);
	setcookie($cookie_name, $lang, time()+31536000, $cookie_path, $cookie_domain, $secure);//one year
	//two weeks 1209600
}
英文:

I have a function and it's getting

> Deprecated: setcookie(): Passing null to parameter #5 ($domain) of
> type string is deprecated on php version 8.2.

That function is below...

function qtranxf_setcookie_language($lang, $cookie_name, $cookie_path, $cookie_domain = NULL, $secure = false){
	qtranxf_dbg_log('qtranxf_setcookie_language: lang='.$lang.'; cookie_name='.$cookie_name.'; cookie_path='.$cookie_path);
	setcookie($cookie_name, $lang, time()+31536000, $cookie_path, $cookie_domain, $secure);//one year
	//two weeks 1209600
}

答案1

得分: 1

你只需要将$domain设置为""而不是null:

function qtranxf_setcookie_language($lang, $cookie_name, $cookie_path, $cookie_domain = '', $secure = false){

英文:

As the warning message indicates:
You just hve to set $domain to "" instead of null:

function qtranxf_setcookie_language($lang, $cookie_name, $cookie_path, $cookie_domain = '', $secure = false){

huangapple
  • 本文由 发表于 2023年6月19日 13:14:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76503778.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定