Set Value

This sets the client variable with name "variableName" to the "value":

context.ClientVariables.SetValue(variableName, value)

context.ClientVariables.SetValue(variableName, value, "Maximum Age in Seconds")

Be aware that cookies are generally deleted by the browser when the browser is closed. If you want the cookie to last longer, give it a maximum age. For example, to set a cookie that is good for one week, you would use:

context.ClientVariables.SetValue("CustomerPortalCartNumber", "my cart number", 604800)