Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

cookies not working in wordpress

10:59 am on Nov 2, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Aug 7, 2008
posts: 93
votes: 0

I am having difficult time handling cookies on a wordpress theme I am developing.

The site needs to drop a cookie on visitor computer so we know that the visitor has opted-in. after then we have to check that cookie value to be 1990 (eg) and then show the membership contents.

I know we can do this by using wp login system too, but for some reasons we do not want to use it. I have to do it thru cookie system so the user doesn't have to login everytime they visit.

I tried adding cookie with path/domains and without it too, but both do not work properly. sometimes it writes the cookie and does not read. sometimes it reads the old cookie.

please please help.

3:38 pm on Nov 2, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
votes: 0

Most likely you are setting an invalid date string, so it's defaulting to a session cookie? Let's see the code of how you set the cookie.
6:11 pm on Nov 2, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Aug 7, 2008
posts: 93
votes: 0

Yeah I know I am doing something wrong. here is the code. I am using to set the cookie and retrieve the cookie in wordpress theme

setcookie("OptPressSqueeze","1990", $cookie_expiry);

retrieving this cookie
echo $_COOKIE['OptPressSqueeze'];

I read somewhere that cookies work with path and domains only in WordPress and WP doesn't allow the cookies to work without path and domain. I tried that way also, but no luck.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members