I want to use cookies with my program.
I can add the cookie and save this for logging in.
However when I restart the server I loose the session I'd. Well I think that is what happens.
How can I get around this.
I would like the person to be automatically logged in when they log into my all new forum.
The server can issue the session an access token stored in a cookie once that session had logged in. That same access token is stored on the server in a database or KeyValueStore. You can check for the presence of a valid token in a Filter. If the server is restarted, the database or KeyValueStore will remain intact, with the list of valid access tokens.
Sessions are stored in the server memory. They are not persistent.
If you want to store a cookie on the client browser then you need to start with a regular handler (not WebSocket) and then add the cookie with resp.AddCookie. Later you can get this cookie with WebSocket.UpgradeRequest.GetCookies.
An access token can be anything. Like a randomly generated 6 digit number, for instance. Store it in a database or a KeyValueStore (something that will persist past a server restart). When a user logs in, set a Cookie with token=123456 (or whatever) and then you can check to see if that Cookie's token value is in your database whenever that user comes back to your site.