title: Rails 3.0 iPhone session
body: <p>I create a session passing user id and password to  a rails 3.0 server.<br>
  In</p>
  
  <pre><code>- (void)connection:(NSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)response     
  </code></pre>
  
  <p>I get the allHeaderFields dictionary from the response and it has a "Set-Cookie" value. </p>
  
  <pre><code>"Set-Cookie" = "_quest_svr_session=BAh7ByIPc2Vzc2lvbl9pZCIlNDRmOTUyZmI2OTZlZTIzMDdlZDg2ZmI5ZTZhM2E4YTA6E3JlbWVtYmVyX3Rva2VuWwdpBiJFMDE1ZjE5OWJkMzU2YzMwNzE2ZjAxMTVhMzI4OTI0MzY3ODU0OTJmZTIyZmE3ZDFmZjdhM2ZiMDdlODFhZWZjMA%3D%3D--38aa7c663ccf53ddd39a0ded89c6f87da5b2abad; path=/; HttpOnly";
  </code></pre>
  
  <p>I store the value in </p>
  
  <pre><code>NSString * session_token =[dictionary objectForKey:@"Set-Cookie"];
  </code></pre>
  
  <p>When I create an NSMutableURLRequest I set the cookie value to the store session token</p>
  
  <pre><code>[theRequest setValue:session_token forHTTPHeaderField:@"Cookie"];
  </code></pre>
  
  <p>The problem is that the rails server is doing a redirect to the sign in page in the rails controller I use</p>
  
  <pre><code>before_filter :authenticate, :except =&gt; [ :new, :create, :templates]
  </code></pre>