Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

PIVOTAL LABS
Standup 8/18/2010: Time#to_json in milliseconds, Encoded vs. encrypted Session Cookies

Interesting

  • Make Ruby Time#to_json always return time in milliseconds: It turns out that while Firefox and Chrome can, Safari cannot parse the default time format that Time#to_json produces. The team decided to override Time#as_json to return an integer number of milliseconds, which to_json will then render into a string (JavaScript can easily work with number-of-milliseconds-since-the-start-of-the-epoch).
  • A pivot wanted to remind everyone that in Rails 2.x, session cookies are not encrypted. Reassuringly, all present were already aware of this. Session cookies are Base64 encoded, and if you ever need to take a look at their contents, here’s how. If you want to encrypt your session cookies, there are Rails plugins available for that purpose.

Comments
  1. Alex says:

    Did you end up just using Time#iso8601? As I understand it, that’s the *only* valid JSON time format.

  2. Joseph Palermo says:

    Yeah, using time in milliseconds seems dangerous because you have lost the UTC offset portion, which may be important depending on how you are using the values.

  3. Davis W. Frank says:

    We did not use Time#iso8601. And Joseph, we let Date.new().toString() handle the timezone values for us on the client.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *