How do I maintain a Javascript function in the DOM even after a page load from another page?

1

As far as I know, it is not possible to maintain the state of the DOM even after page load, is there any technique or some way out to keep the function in cookie or storage (local, session) to later give eval ()?

    
asked by anonymous 27.01.2015 / 12:17

1 answer

3

I do not advise keeping the information in function . It would be best to modify the code and store only the required keys.

In addition, local storage is not recommended for storing session information or "sensitive" data ( source >).

In this case, it would be more appropriate to use a cookie . If possible, use HTTPS and the flag secure enabled, which helps to avoid some man-in-the-middle attacks. As you need to access the key in JavaScript, you will not be able to fire httpOnly , so your page will be susceptible to Cross-Site Scripting (XSS) attacks.

But understand that any key recorded in the client does not offer good levels of security, it almost does not even use any session id , anyway anyone who can access their page information replicate the "natural" behavior of the system.

    
27.01.2015 / 15:29