0

if you render your page with JS and need to implement a security feature, it comes down to something such as this:

var userID = getUserID();
if (userID == 1) {
   html += renderDeleteButton();
}

But won't the user be able to just open the debugger and change the value of userID ?

1
  • It’s more important that the function cannot be executed by unauthorized users. Commented Jul 28, 2012 at 7:46

3 Answers 3

8

Yes they will. With JS, the user can do whatever the heck they want. This is why security stuff should go in your server-side code (PHP / ASP / etc.), as users cannot modify it.

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

Comments

2

Do not trust anything from a client side script like JS. All client side scripts can be manipulated by the user. Any secure type of code should reside in a server side script.

Comments

1

Validation/security checks in javascript are always only done to save the user the time of a trip to the server and back. They are strictly for performance only.

If you want actual security, it must be implemented on the server.

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.