I'm assuming you're relying on front end tools. When you refresh, you will load the same HTML/CSS/JavaScript every time. Therefore, you will always have your original settings. You can make the collapse default (everytime you go under a certain width, the menu/bar collapses and has to be clicked/toggled to be uncollapsed). This is a pretty standard for collapsable navbars. However, if you want to be able to go beneath a certain width while not collapsed is the default, have the user toggle it, and save that collapsed status, then you need something more than just JavaScript/HTML/CSS.
If you use php, you could save a session status./cookie as collapsed, whenever the toggle is clicked, and then on reload, the menu would collapsed. Basically, you need a backend language to store a cookie or session.