Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Mar 04, 2013 12:21 am 
Offline
Senior Newbie

Joined: Sun Mar 03, 2013 11:44 pm
Posts: 6
I moved my website from Bluehost to Linode, and everything's working well... well, almost.

I must shamefacedly confess to bad programming practice, as I have one page write a cookie and the form handler (a separate PHP file) then reads that cookie. Don't ask me why I am doing this (well, you really should, to expose me for the hack that I am... maybe I will learn something here.

Finally, I narrowed it down in the debugger to when I set the document.cookie object using JavaScript. On the working site (Bluehost), document.cookie gets set to the cookie value. On my Linode environment, using the LAMP stack, it does not. Aargh. FWIW, here's the code:

function formSetCookie(c_name,value,expiredays)
{
var exdate=new Date();
//var sNewVal = value.replace(/ /g,"+");

exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : "; expires="+exdate.toGMTString()) +
"; path=/; domain=worldbento.com";
}

Should path be "/" or something else?

Any ideas appreciated, folks. I am real excited about Linode, but just want my site to migrate seamlessly.

Vik


Top
   
PostPosted: Mon Mar 04, 2013 6:56 am 
Offline
Senior Member
User avatar

Joined: Tue Jan 04, 2005 7:32 am
Posts: 277
Website: http://www.betadome.com/
Location: Ă…lesund, Norway
Skype: neonnero
Twitter: neonnero
You've specified the domain in your cookie as "worldbento.com", which means that if the URL you're on doesn't begin with http://worldbento.com/, the cookie can't be read. Unless you require it to be on a specific domain, you don't need to set the domain for a cookie, which means that it will be set to whichever domain you're already on (ie. based on the current web page URL).


Top
   
PostPosted: Mon Mar 04, 2013 10:58 am 
Offline
Senior Newbie

Joined: Sun Mar 03, 2013 11:44 pm
Posts: 6
That's a reasonable suggestion. However, the domain is "worldbento.com", and the cookie is not being written in the first place. Is there a configuration setting for Apache that controls whether cookies can be written or not (I checked my php.ini file to check all the cookie settings). Thank you for your reply.


Top
   
PostPosted: Mon Mar 04, 2013 11:33 am 
Offline
Senior Member
User avatar

Joined: Tue Jan 04, 2005 7:32 am
Posts: 277
Website: http://www.betadome.com/
Location: Ă…lesund, Norway
Skype: neonnero
Twitter: neonnero
Since you're setting the cookie through JavaScript, neither the Apache configuration or php.ini have anything to do with this issue.

Checking the page source directly, I find this snippet here: http://worldbento.com/common/javascript/form.js. In here, it references the "gk_DOMAIN" variable for the domain part of the cookie (line 37). On the next line, it says that this variable is set in the tracking.js file. Thing is, it's hard to tell whether the variable comes from tracking.js or _tracking.js, where the gk_DOMAIN variables are set to two different values. In any case, when I have loaded the worldbento.com website, and enter the URL "javascript:alert(gk_DOMAIN)" (making JavaScript pop up an alert box showing me the value of that variable in this context), the pop-up box tells me it's set to "indianbento.com".

Basically, it's setting the cookie's domain to "indianbento.com", rather than "worldbento.com". I tried this in Opera, but I'd assume this happens in other browsers as well.

This is why I was asking why you couldn't just remove the domain parameter for the cookie, allowing the browser to handle this part by itself (not setting the domain would just make it valid for the current domain of the web page's URL).


Top
   
PostPosted: Mon Mar 04, 2013 12:04 pm 
Offline
Senior Newbie

Joined: Sun Mar 03, 2013 11:44 pm
Posts: 6
Thank you for checking it out NeonNero, I will try that and see if it fixes the problem. If you are seeing the domain as being "indianbento.com" (different from the one that the code is running on - worldbento.com), then that could definitely be the problem. Appreciate it!


Top
   
PostPosted: Wed Mar 06, 2013 11:17 am 
Offline
Senior Newbie

Joined: Sun Mar 03, 2013 11:44 pm
Posts: 6
Hail to NeonNero!

That definitely was the problem. I'm just beginning to learn how to use the Chrome JavaScript debugger better, and didn't even realize that I could put a watch on the variable. It turned out that I had not updated my minified JS file _tracking.js, and so it was using the old domain.

Thank you very much!
Vik


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group