I have 2 pages
function.php
function getcookie()
{
if (!empty($_COOKIE['remember'])) {
$test="testing function";
}
}
And home.php
include('function.php');
getcookie();
echo"$test";
I get this error - Notice: Undefined variable: test in .... when I call the getcookie function and meanwhile the cookie is set.
When I try it like this, it works.
home.php
if (!empty($_COOKIE['remember'])) {
$test="testing function";
}
echo"$test";
Result - testing functon