javascript - Is it safe to use hidden inputs to retrieve user data? -


I have a huge form divided into 5 subforms. When you go from form1 to form2, then given in Form 1 The information is stored in DB and userID is created. Then this userId in form2 has been added as a hidden input. Something like this:

  & lt; Form action = "" method = "post" & gt; & Lt; Input type = "hidden" value = "userIDnumber" id = "userId" /> & Lt; Input type = "hidden" value = "& lt ;? php echo base_url () ;? & gt;" Id = "url" /> // Form data & lt; Input type = "button" id = "prevButton" value = "previous" /> & Lt; Input type = "submit" value = "next" /> & Lt; / Form & gt;   

If the user decides that to edit the data, go back to Form 1, clicking on the 'Back' button becomes the following:

  var prev = document querySelector ('# prevButton'); if (! prev.addEventListener) {prev.attachEvent ('onclick', prevpage); } else {prev.addEventListener ('click', previous page, incorrect); } Function prevpage (e) {var userId = document.getElementById ('userId'). value; var url = document.getElementById ('url') value; var form = document.createElement ('form'); form.setAttribute ('method', 'post'); form.setAttribute ('action', url + 'form / 1'); form.style.display = 'hidden'; var input = document.createElement ("input"); Input.setAttribute ("type", "hidden"); Input.setAttribute ("name", "userId"); input.setAttribute ("value", userId); form.appendChild (input); document.body.appendChild (form); Form.submit (); }   

What I am doing is a hidden form and in this form a hidden field is being paired with UserId, so that when I am going to Form 1, then that data I can retrieve the user who has posted just update the database in return for anything

My question is, is this a safe way to recover user data? I'm very new to JavaScript, so I'm not sure that working on this way is a way to access the other user's data by putting their ID directly to the attacker.

If so, what is the safest way to do this? I probably thought about using sessions, but the user I'm working for does not want to login to the user.

I have not got any questions about this, but if I apologize and please please tell me where it is.

Thank you for your time.

When a user accesses my web page, then I create a global object in which I Create user namespace:

  APP.user = {};   

In this object, you can store the properties you need and when the user logs in, you can retrieve the user data with the Ajax server.

Object example with key-value pairs in a simple browser memory:

  APPUser = {user_id: 'kgy', first name: 'Kim', last Name: 'Gysen',}   

Actually, this data is also publicly available.
DOM / Storing data in global object space is never safe when it is related to sensitive data.
Of course, the user must log in to access these data anyway.

One thing is that this approach will be faster, because there is no need to crawl the DOM, just to get some local user data on different pages.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -