Essentially I want to store a variable in the client that I don’t want people viewing or changing.
In the following code example:
(function () {
var foo = 'bar';
})();
Can anybody use tools or the browser to access and/or (more importantly) change the value of foo? Links to more information or tools that might do this would be appreciated. I’ll be researching more in the mean time.
Thanks in advance
Yes they can modify the values of foo. As a general rule, if you don’t want the client to manipulate the value, don’t give them access to it (I.e. put user id’s or this type of information in the DOM or client side). You may have to do a bit of
state managementresearch, encrypted cookies, sessions or if you’re usingASP.NETtheViewState/ViewBagetc.