Internationalization is no simple mattertm
JS URL Encoding
Sometimes we want to pass a free-text user-input string in the URL, which may be at any language. At work, we used the escape() JS built-in function to make a UTF-8 legal URL. *WRONG*
Internationalization is no simple mattertm
JS URL Encoding
Sometimes we want to pass a free-text user-input string in the URL, which may be at any language. At work, we used the escape() JS built-in function to make a UTF-8 legal URL. *WRONG*
At work we have a page that loads multiple PHP scripts (in parallel), using XMLHttpRequest.
Later, we noticed that if one PHP script responds very slowly (i.e. when we put sleep(120) inside), all the others are waiting till the first one finishes loading. In other words: the load is serial, not parallel!
What? Why?!
A little research revealed an interesting phenomena: PHP session locks the session file till the session is closed. By default, the lock starts with session_start() call, and ends at the end of the PHP script!
Many websites use session-cookies (PHP session installs such a cookie, for example). Session-cookies have expiry time of zero, and the browser usually deletes them after closing its window. This is very useful for a 'log-in' session, like in your bank account, gmail, etc.
So all browsers delete the cookie as you close them, but what happens when you open a new browser window or tab? Does it also respect this temporary, session cookie? If you're logged in to gmail from one window, can you open a new browser window with another gmail account?
The answer is not surprising: that depends on your browser.
After some struggling with how the Daylight Saving Time change affected my code, I realized that one shouldn't mess with the time zone offsets on his own (i.e. Add or Subtract hours manually from the UTC time), because underlying libs already implement it - and probably better (yes, including DST changes, works flawlessly!). Here are the new simple rules I set to myself:
Bottom line: stick to UTC as much as you can, it's good for you.
Trivia line: Morocco is GMT+0 and has no Daylight Saving Time (so it's identical to UTC). Good for them, eh?