Search code examples
angularjscookiessession-cookiesangular-translate

Angular-Translate cookie storage path


I'm using angular-translate with cookie storage as described here: https://angular-translate.github.io/docs/#/guide/10_storages

The cookie is being stored in the session under the default key, however it is also applying a unique path to the cookie and the result is not remembering the language key across http requests.

Example:

If user is on the /Account page and set their language, the cookie is as follows:

Name: NG_TRANSLATE_LANG_KEY

Path: /Account

If the user is on the profile page:

Name: NG_TRANSLATE_LANG_KEY

Path: /Profile

The result is that the language is remembered for their specific pages, but not across the entire application. Is there a method to set the Path for the entire domain? The expected result is that wherever a lanauage preference is set, that language is used across the entire application.


Solution

  • ng1.3.15 doesn't support editing the cookie path. ng1.4 does include a change that allows for changing the path.

    However, the business criteria was solved by using localStorage. If changing the cookie path is desired, ng is required to be updated.