Created
December 8, 2008 14:42
-
-
Save delagoya/33471 to your computer and use it in GitHub Desktop.
Setting session cookies from flash in Merb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is Merb middleware to set a session cookie when the request comes from flash. | |
You must first require the module, then invoke it's use in the call chain in either rack.rb or config.ru. | |
Examples below. Note that SWFUPload by default adds a lot of post parameters with non-standard | |
ruby variable names, so merb-action-args will choke a bit on that unless you customize SWFupload | |
or just not use action-args. | |
Also note that the session information must be set as a GET parameters, e.g. in the URL request like so: | |
SWFUpload.onload = function () { | |
var settings = { | |
flash_url : "/flash/swfupload.swf", | |
file_post_name: "attachment", | |
upload_url: "#{url(:upload_attachments,@attachment)}?_session_id=#{cookies[:_session_id]}", | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Phusion passenger rack up file, as an alternate to the Merb's rack.rb | |
## ... other code | |
Merb::BootLoader.run | |
use Merb::Rack::SwfSetSessionCookie, Merb::Config[:session_id_key] | |
run Merb::Rack::Application.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Merb rack.rb file, set the use of this middleware. Make sure it has been required already | |
## ... other code ... | |
use Merb::Rack::SwfSetSessionCookie,Merb::Config[:session_id_key] | |
run Merb::Rack::Application.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment