Answers.Body: <h2>Storing the cookie</h2>
  
  <p>I'd recommend using the <a href="https://github.com/lewisjenkins/craft-lj-cookies" rel="nofollow noreferrer">LJ Cookies plugin</a>...</p>
  
  <pre><code>{% do craft.lj_cookies.set('locale', craft.locale, '', '/' ) %}
  </code></pre>
  
  <h2>Retrieving the cookie</h2>
  
  <p>The LJ Cookies plugin is also capable of reading cookies, so you could simply put a conditional redirect at the top of your layout...</p>
  
  <pre><code>{% set currentLocale = craft.locale %}
  {% set goToLocale = craft.lj_cookies.get('locale') %}
  
  {% if goToLocale and (currentLocale != goToLocale %}
      {% redirect '/' ~ goToLocale %}
  {% endif %}
  </code></pre>
  
  <p>If you insist on performing the locale redirect at the .htaccess level, that's also possible. It would provide you a small performance improvement, but may not be worth bypassing the simplicity of using LJ Cookies in your template.</p>
  
  <p>Using .htaccess to perform a redirect based on a cookie value is beyond my expertise, and somewhat beyond the scope of the Craft SE site. But I did some quick Googling around for "cookie" and "htaccess", and found a few helpful links:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/3978726/how-to-do-htaccess-redirect-based-on-cookie-value">https://stackoverflow.com/questions/3978726/how-to-do-htaccess-redirect-based-on-cookie-value</a></li>
  <li><a href="http://www.askapache.com/htaccess/htaccess-fresh.html#Get_Cookie_Value" rel="nofollow noreferrer">http://www.askapache.com/htaccess/htaccess-fresh.html#Get_Cookie_Value</a></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-24T05:58:21.547Z
Answers.LastActivityDate: 2015-03-24T05:58:21.547Z
Answers.LastEditDate: 2017-05-23T12:38:53.957Z
Answers.UserDisplayName: Lindsey D
Body: <p>If we are storing a cookie of a locale the user choose, is there a way to detect that cookie in htaccess so the next time they visit the base url of the site it will take them to the same locale?</p>
  
Tags: <localization><htaccess>
Title: Return to specific locale based on cookie?
ThreadText: # Return to specific locale based on cookie?
  
  (Asked by: username_0 on 2015-03-24)
  
  If we are storing a cookie of a locale the user choose, is there a way to detect that cookie in htaccess so the next time they visit the base url of the site it will take them to the same locale?
  
  **Tags:** localization, htaccess
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-03-24. Score: 3 | Accepted answer
  
  ## Storing the cookie
  
  I'd recommend using the [LJ Cookies plugin](https://github.com/lewisjenkins/craft-lj-cookies)...
  
  ```
  {% do craft.lj_cookies.set('locale', craft.locale, '', '/' ) %}
  
  ```
  
  ## Retrieving the cookie
  
  The LJ Cookies plugin is also capable of reading cookies, so you could simply put a conditional redirect at the top of your layout...
  
  ```
  {% set currentLocale = craft.locale %}
  {% set goToLocale = craft.lj_cookies.get('locale') %}
  
  {% if goToLocale and (currentLocale != goToLocale %}
      {% redirect '/' ~ goToLocale %}
  {% endif %}
  
  ```
  
  If you insist on performing the locale redirect at the .htaccess level, that's also possible. It would provide you a small performance improvement, but may not be worth bypassing the simplicity of using LJ Cookies in your template.
  
  Using .htaccess to perform a redirect based on a cookie value is beyond my expertise, and somewhat beyond the scope of the Craft SE site. But I did some quick Googling around for "cookie" and "htaccess", and found a few helpful links:
  
  * <https://stackoverflow.com/questions/3978726/how-to-do-htaccess-redirect-based-on-cookie-value>
  * <http://www.askapache.com/htaccess/htaccess-fresh.html#Get_Cookie_Value>
  
  
  ---
  
  