如何在Rails中设置cookie?我需要相当于这个PHP代码:
<?php
setcookie("AFID", $_REQUEST['AFID'], time() + (60*60*24*365));
setcookie("SID", $_REQUEST['SID'], time() + (60*60*24*365));
?>
答案 0 :(得分:4)
这很直接:
cookies['AFID'] = {
:value => request.env['AFID'],
:expires => 1.year.from_now
}