Welcome Guest, Not a member yet? Register   Sign In
cookie library and helpers doesn't work
#1

I'm trying to set a cookie to count how many visitors(hits) my posts already have. But the cookie is not sent, what I'm doing wrong?? In my debugging i get "null", or if I try dd($_COOKIE[$cookieName] i get an error.

PHP Code:
if (! has_cookie($cookieName$ipVisitante"__HitPost-")) {
            $cookie = (new Cookie($cookieName))
                ->withValue($ipVisitante)
                ->withPrefix('__HitPost-')
                ->withExpires(new DateTime('+2 hours'))
                ->withPath(current_url())
                ->withDomain(base_url())
                ->withSecure(false)
                ->withHTTPOnly(false)
                ->withSameSite(Cookie::SAMESITE_LAX);

            set_cookie($cookie);
 }

        dd(get_cookie($cookieName), get_cookie("__HitPost-$cookie"), $_COOKIE); 
Reply
#2

The following values are invalid.

                ->withPath(current_url())
                ->withDomain(base_url())
Reply




Theme © iAndrew 2016 - Forum software by © MyBB