functions - custom COOKIE on custom page

admin2025-01-08  4

i have problem with create function for set cookie dynamically.

when i try in custom page i have of course header is set and i tried something like this: in custompage.php:

myfunction($cookiename,$cookievalue);

in function.php

add_action("init","myfunction",10,2);
function myfunction($name,$value) {
setcookie($name,$value,time()+3600);
}
add_action("wp_head","mySEOfunction",10,2);
function mySEOfunction($name,$value) {
echo "some meta tags...".$name...
}

i have Missing argument 2 in function.php i tried also this for SEO meta tags created dynamically but i have same problem...

any help?

i have problem with create function for set cookie dynamically.

when i try in custom page i have of course header is set and i tried something like this: in custompage.php:

myfunction($cookiename,$cookievalue);

in function.php

add_action("init","myfunction",10,2);
function myfunction($name,$value) {
setcookie($name,$value,time()+3600);
}
add_action("wp_head","mySEOfunction",10,2);
function mySEOfunction($name,$value) {
echo "some meta tags...".$name...
}

i have Missing argument 2 in function.php i tried also this for SEO meta tags created dynamically but i have same problem...

any help?

Share Improve this question edited Dec 7, 2015 at 10:29 user1721620 asked Dec 6, 2015 at 23:39 user1721620user1721620 1012 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

If all you are doing is setting a cookie on a page then why the complexity? Check this out for a simple answer http://www.w3schools.com/php/func_http_setcookie.asp

My only thought is that you are then trying to redirect them back to Wordpress and if so you may wish to check this Setting custom cookies in Wordpress

I'd say your error "missing function 2" is coming from incorrect syntax for time.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736266717a1142.html

最新回复(0)