ruby on rails - Sinatra cookies resetting between routes -
so i'm trying pass strings through cookies between routes, keep getting reset , don't passed along. here code:
post '/start_game' @game = tictactoe::game.new cookies[:board] = @game.board.slots redirect '/game' end post '/game' @slots = cookies[:board] end i've tried request.cookies[:board], , using quotes instead of using symbols.
i think because setting cookie on 1 path , reading on different one. /start_game considered different part of site /game cookie point of view. can solve problem setting cookie @ / level:
response.set_cookie(:board, { :path => '/' }) you should not need change way read (because other path sub-path of /).
Comments
Post a Comment