You could use $.ajax to avoid the natural behaviour of <form method="POST">.
You could, for example, add an event to the submission button and treat the POST request as AJAX.
XMLHttpRequest Level 2 adds support for the new FormData interface. FormData objects provide a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequestsend() method.
app.get('/',function(req, res){
var token = req.cookies.token
});
Note that httpOnly:true ensures that the cookie is usually not accessible manually or through javascript and only browser can access it.
如果您希望通过表单发送而不是通过 ajax 发送一些标头或安全令牌,那么在大多数情况下,这可以被认为是一种安全的方法。不过,如果您存储了一些敏感的用户相关信息(通常都是这种情况) ,请确保数据是通过安全协议/ssl 发送的。