0

I am storing some sensitive data on javascript side. How can I prevent user from tampering these data. I can not do this on server side with ajax or anything else, as smoothness of the animation concerned.

4
  • is it possible anyway to control other's browser??? Commented Oct 28, 2014 at 11:36
  • How do you cram so much "wrong" into so such a short sentence...? Don't store sensitive data client-side - it's that simple! Commented Oct 28, 2014 at 11:38
  • Store "sensitive data" on javascript side? IMO both concepts together on a sentence are wrong. Commented Oct 28, 2014 at 11:41
  • @Emissary: Seems like you've edited the comment - it looked like you were critiquing the grammer. Commented Oct 28, 2014 at 11:43

1 Answer 1

2

Make your JavaScript inaccessible to someone using function scope etc. This isn't perfect but it can certainly make things a lot harder. For example, if you define:

var f = function() { return "test"; }
f();

Then it's easy to call window.f()

If instead you define as a self invoking function then you've just made it much more difficult for someone to call:

(function() { 
return test;
})();

This principle can then be extended - any variables defined within the function, will only have scope within it making it very difficult (but probably not impossible) to get hold of them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.