Functional testing - why can you use session[:key] but not s

Question’s all in the title…

def test_foo
assert_equal ‘foo’, session[:bar] # Perfectly valid
end

def test_blowup
session[:bar] = foo # TypeError: Symbol as array index

end

I always create a @session variable in the setup method. Just curious
as to why you can get session values but not set them using session[]

Pat