nuahssiaram Posted December 13, 2011 Share Posted December 13, 2011 Hi, I have just started learning php and I am trying to make a mobi site send a cookie so that visitors can switch between mobile and full site views. I feel like I have tried everything. I don't think the cookie is sending. I am using Google Chrome to search for the cookie, but nothing comes up. Is the following code right?I have placed it on the first line of code "before any html is sent"(according to the tutorials). <?php $expireDate = time() +3600; setcookie("testcookie", "formywebsite", $expireDate, "/", "mobi.website.com");?> Link to comment Share on other sites More sharing options...
birbal Posted December 13, 2011 Share Posted December 13, 2011 how do you know it is not seting the cookie? how did you checked it? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 13, 2011 Share Posted December 13, 2011 Make sure the domain matches the site you're testing on. This may not work if you're testing on localhost. Link to comment Share on other sites More sharing options...
nuahssiaram Posted December 14, 2011 Author Share Posted December 14, 2011 Thanks, it's working. Total noob moment. I didn't save as .php(when you think you've tried everything there still is one more thing) Link to comment Share on other sites More sharing options...
nuahssiaram Posted December 14, 2011 Author Share Posted December 14, 2011 I check cookies by using Google Chrome's 'show all cookies' Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.