Codingcookie voodoo

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  CHYRON (DSMITHHFX)  
 To:  ALL
41539.1 
I just published a web site that uses cookie vars to dynamically load content via js. It was working great on three different servers (including live) as of yesterday, this morning the live version menuing stopped working. Only difference between live, staging and development servers is the site is in a "public_html" root of the live server, and the live server is zeus (others are apache).

If I put a copy into a subdirectory on the live site, it works, cookies and all.

Any iDears?

----
"Giant pig hot air balloon crashes after tangling with a cowboy-shaped one"
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  CHYRON (DSMITHHFX)     
41539.2 In reply to 41539.1 
> this morning the live version menuing stopped working.
> Only difference between live, staging and development servers is ....

1. Real Staging servers use the same (or closest possible) setup as Live.

2. Computers are automatons - if their behaviour changes it's because they were told to change. If the software doesn't differentiate between environments or yesterday then something else changed - so the poor server setup is not the only difference, and your first step is to identify which other differences exist.


> If I put a copy into a subdirectory on the live site, it works, cookies and all.

Check your version control history for what changes were made - sounds possible that somebody may have set/changed the path attribute of the cookies. Then again, you would have spotted that when you compared the actual cookies for the different environments to check for differences, so maybe it's something else.

0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)  
 To:  Peter (BOUGHTONP)     
41539.3 In reply to 41539.2 
I did make some edits to the javascript yesterday unrelated to the cookies stuffs. I'll do a diff compare to previous version on monday.

----
"Giant pig hot air balloon crashes after tangling with a cowboy-shaped one"
0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)  
 To:  ALL
41539.4 
Problem solved by deletion of a single caricature.

Before:
Code: 
document.cookie.match(/^foliosec=[a-z]+/) + '';
After:
Code: 
document.cookie.match(/foliosec=[a-z]+/) + '';

----
"Giant pig hot air balloon crashes after tangling with a cowboy-shaped one"
0/0
 Reply   Quote More 

 From:  99% of gargoyles look like (MR_BASTARD)  
 To:  Peter (BOUGHTONP)     
41539.5 In reply to 41539.4 
G'wan, tell him the difference between 'caricature' and 'character', and let him squirm at his risible use of language. You know you want to.

truffy.gifbastard by name
bastard by nature

0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)  
 To:  99% of gargoyles look like (MR_BASTARD)     
41539.6 In reply to 41539.5 
Caricature: you. Character: Peter.

You're welcome.

----
"Giant pig hot air balloon crashes after tangling with a cowboy-shaped one"
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  CHYRON (DSMITHHFX)     
41539.7 In reply to 41539.4 
Except now it'll also match any cookies with names ending in "portfoliosec".

If JS had a decent regex engine, you'd just use a lookbehind instead (?<=^|;) but it doesn't so that wont work.

Next best solution is probably splitting and looping:

FoliosecCookie = getCookie('foliosec');

function getCookie( Name )
{
	for ( CurCookie in document.cookie.split(';') )
	{
	    var KeyValue = CurCookie.split('=',2);
	    if ( KeyValue[0] == Name )
	       return KeyValue[1];
	}
	return '';
}

You may need to use decodeURIComponent on the return value.

And for anyone wondering why the browsers don't just provide a built-in getCookie method that accepts a name and returns the value, the answer is because browser developers are fucking stupid.

0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)  
 To:  Peter (BOUGHTONP)     
41539.8 In reply to 41539.7 
I could have tried
/; foliosec=[a-z]+;/
but I was too lazy to find out if semi-colons need to be escaped (as seems likely), didn't want to start faffing around with regex voodoo, and was tickled by the one-caricature fix (apologies to bastard for that).

The likelihood of another cookie that includes "foliosec" as part of its name in this site is remote.

I'm considering whether using cookies makes the whole thing a bit too fragile, and will try url-based variables instead, which is how e.g. angularjs does it.

----
"Giant pig hot air balloon crashes after tangling with a cowboy-shaped one"
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  CHYRON (DSMITHHFX)     
41539.9 In reply to 41539.8 
Semi-colon doesn't need escaping. Only these do: ^.$*+?\|()[]{}

And it really isn't voodoo; it's a very easy language to learn.

0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)  
 To:  ALL
41539.10 
Got the URL-based vars coded up without too much trouble (even learned the simple trick of rewriting the URL hash on the fly) and it seems considerably more responsive than the cookie vars. Probly make the patches live tomorrow.

----
"Giant pig hot air balloon crashes after tangling with a cowboy-shaped one"
0/0
 Reply   Quote More 

Reply to All    
 

1–10

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats