Dester Dezzods
Dester Dezzods

Reputation: 1535

set cookies in parent directory php

My directory structure is as follows:

How can i set cookies from login.php in the parent directory so that I can use them in homepage.php.

I've tried setcookie("userid",$row["userid"],time()+3600,"../"); to set cookie and print_r($_COOKIE); in homepage.php doesn't show any cookies

Upvotes: 0

Views: 2297

Answers (1)

Sébastien
Sébastien

Reputation: 12139

Just use / as the cookie path. That way your cookie will be available to your entire domain.

setcookie('userid', $row['userid'], time() + 3600, '/');

Regardless of where you set it and where you retrieve it, it will be available via $_COOKIE['userid'].

Upvotes: 8

Related Questions