Using cookies in Universal Rendering using angular-cli -


i have made angular app using angular-cli , doing universal rendering in following steps given here . mentioned can't use global variables window , document in app if doing universal rendering, how can set cookies @ front end maintain user session. using jwt, doing need set cookies in browser.

i have had success using npm package ng2-cache (i using angular 4 , works fine). using local storage, have in module providers array this:

providers: [     cacheservice,     {provide: cachestorageabstract, useclass: cachelocalstorage},     ... ] 

another option use isplatformbrowser() shown here.

the ugliest option put code dealing cookies in try-catch statements. way work on browser , ignored on server side.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -