homepage Welcome to WebmasterWorld Guest from 107.21.186.38
register, login, search, subscribe, help, library, PubCon, announcements, recent posts, open posts,
Pubcon Website
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library : Charter : Moderators: coopster & eelixduppy & jatar k

PHP Server Side Scripting Forum

    
cookies not working in wordpress
hozyali




msg:4225326
 10:59 am on Nov 2, 2010 (gmt 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.

Thanks

 

rocknbil




msg:4225448
 3:38 pm on Nov 2, 2010 (gmt 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.

hozyali




msg:4225566
 6:11 pm on Nov 2, 2010 (gmt 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


$cookie_expiry=time()+60*60*24*30;
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.

thanks

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
WebmasterWorld ® and PubCon ® are a Registered Trademarks of Pubcon Inc.
© Pubcon Inc. 1996-2012 all rights reserved