Cookies and relLangURL

Hello,
I’m working on a multilingual site and right now I’m trying to understand how I can maintain a user-chosen language across the pages s/he visits.
The site has a search system and whatever the language of the Search page, the Results page is always in (default) English.
I understand I should use relLangURL somehow - are there any followable description?

Right now I have search output in this form:

`<h4><a href="${item.permalink}">${item.title}</a></h4>`);

Is it possible to use relLangURL to maintain the language?

If I use cookies to record the user language, how can I assign the language value using cookies and relLangURL?

I’ve solved the issue and want to share some info with those who may be dealing with the same problem:

  1. use relLangURL wherever appropriate and possible, use JS beyond that.
  2. set a cookie and make sure your cookie setting is followed in your URLs.
  3. usually the default language setting is omitted from Hugo URLs - make sure they are omitted from URLs you create.
    That’s it.