英文:
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){
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论