javascript - Change url parameters for bookmark

one text

I have to change the URL parameters as I click on some button filters in order to bookmark that search so in the future I won't have to filter it again.

The initial URL looks somethin like: http://localhost/?view=logs&color=red

And if I click on a filter, I have multiple situations:

1.I click on another color(blue) and the URL should become: http://localhost/?view=logs&color=red,blue

2.I click on another parameter(size) to be 'large' : http://localhost/?view=logs&color=red,blue&size=large

3.I click on 'red' again : http://localhost/?view=logs&color=blue&size=large

I am using javascript and PHP, what are my options for me to be able to change the URL in real time, as I click on the filters and at the end, BOOKMARK it for me to come back to it later? Thank you!

I haven't tried a lot, I'm new to this and I'm trying to figure out how to start this feature.

Source