Redirect_to and the missing session

Hi,

My application responds to a URL along the lines of http://myapp/xxxx
where routes.rb determines that xxxx is not an action but an affiliate
code from a referral from another site. The affiliate is validated
and then the browser is redirected to the ‘new’ action.

def affiliate
reset_session # we should not have any session data set if we
reach here which we will have if we are testing!
affiliate = params[:affiliate] # this is parsed by routes.rb
if Affiliate.validate?(affiliate)
session[:affiliate_name] = affiliate
else
log.info ‘Invalid affiliate’
end
redirect_to :action => ‘new’
end

when I try to access the session data in the ‘new’ action to pre-
populate the object with the validated affiliate name, my session data
is not there. All I have is _csrf_token which suggests that I never
wrote the session in the affiliate action or didn’t send the cookie on
the redirect.

The response I get is:

http://myapp:3000/quote/new
Completed in 120ms (DB: 2) | 302 Found [http://myapp/xxxx]

Does a 302 not send a cookie back to the browser and therefore the
‘new’ action is the first action to use the session and just creates a
new one?

Alternatives? Well I can get it working by passing the affiliate as
part of the url to the ‘new’ action but this then means the url looks
messy, and it could be easily modified so I would have to revalidate
the affiliate all over again.

O.

An update.

I have just created a very simple sandpit application and it works
correctly. See below.

class AController < ApplicationController

def hello
@content = session[:keepthis]
end

def parameter
reset_session
session[:keepthis] = params[:affiliate]
redirect_to :action => ‘hello’
end

end

and a routes.rb is

map.a “a/:action”,
:controller => “a”

map.a “:affiliate”,
:controller => “a”,
:action => “parameter”,
:requirements => { :affiliate => /\w+/ }

Ok. So the new application was generated new on Rails 2.3.4 and the
misbehaving application was built on 2.3.2 and was upgraded to 2.3.4.
I will go and check the release notes but if anyone has any pointers
on this then I would be very grateful.

Thanks.

O.