they are both correct.
one is a server behavior, it creates server side code to create a cookie that is triggered from a server event like the value of a submitted form field.
the second one is a client side behavior that creates javascript code to set a cookie based on a client side event such as the onClick event of a button, or onBlur event of a text field