What is the difference between assignment and put_session in Plug.Conn from Phoenix Framework?

The documentation ( https://hexdocs.pm/plug/Plug.Conn.html ) names two functions that allow you to store a key-value pair inconn

assign(conn, key, value)

Assigns a value to a key in a connection

put_session(conn, key, value)

Sets the specified session value for this key.

What is the difference between these two functions?

+4
source share
1 answer

It basically assignworks only for a specific connection - the Plug.Conn structure - this means that this value will disappear with the completion of the request - since conn will also die - at the end of the request / response cycle.

cookie ets. , . .

TL; :

assign .

put_session , /.

+9

Source: https://habr.com/ru/post/1686680/


All Articles