Safari Version 5.1.3 (7534.53.10) Browser problem --- removing cookie on OS X Lion 10.7.3 (11D50b) w

Hi All,
Hope this note helps the newbies to Rails
As I’m new to Rails, I’d like to share how I tracked down Safari’s
dropping of my cookie.

My Applebug no: 11003492 registered 7 March/2012

My development platform:
MacPro running rails 3.1.1 on OS X Lion 10.7.3 (11D50b)

Firefox worked as programmed but switching to Safari my
current_user_token kept in the cookie[:remember_user_token] became
nil. Later in the debug sessions, this value returned was due to the
cookie being removed by Safari — not present!

The steps leading to Safari dropping of the cookie

  1. signin and set the cookie[:remember_user_token] to
  2. get /index_stats for user — cookie still valid
  3. get /show_stats : rendering the view showed that the cookie value
    returned was nil

How to debug the problem?:

  1. Use the Ruby method set_trace_func to see the source code being
    a) U must be judicious in turning on / off the set_trace_func
    method as it blows out a lot of source tracing.
    b) Use of Unix split utility helped at the beginning to pare down
    the size of file to edit as u could blow up your editor due to size

  2. from the above output it lead me to look at the Ruby source code:

  3. By reading the ruby code and to modify it to output some of its
    values to STDOUT this allowed me to refine the next debugging steps
    to catch the problem . Note use of logger.debug in the above source
    will not work as the logger method is not defined!

  4. I refined my tracing output strategies and ran it against both
    browsers: Firefox and Safari for a comparison analysis.

  5. Running the Unix diff utility against the 2 browser outputs homed
    in on Safari missteps — niled cookie

  6. By inspecting the cookie for both browsers, it showed that Safari
    had removed the cookie[:remember_user_token]
    I sent to Apple these 2 traced outputs as evidence of the Safari

I found set_trace_func a good starting point to see what is happening.
I experimented with ruby-debug but this was too fined-grained for my
current problem at hand.

Hope this helps to your programming efforts.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs