Storing session state

I’m new to the web. How and where to store user information between requests to the server? As I understand it, it should be stored in cookies (not on the server)? Or is it not safe?

UpdateI’m interested in how it works. I write in Go, there are not many libraries there. Task: to implement work with several types of users. Found the Cookietype. Now I am implementing a mechanism for tracking the user through them.

Answer 1, authority 100%

In my opinion, it is better to use a ready-made solution. There is a great gorillalibrary. From personal experience, I can say that it works acceptable, there are complaints about two data stores.

Answer 2

use session_startand then,

$_SESSION['myUserName'] = '';

That’s it, now the $_SESSION variable will have an entry about myUserName