Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are HTML attributes good for storing data?

(Please disregard any security concerns you may have with this approach, I have a already taken more than enough precautions to make sure that there are no blatant vulnerabilities with this approach)

In PHP, I have many values in a table, with a few buttons to perform javascript functions associated with that row.

Example:

<td id="row1" record="1">
<button id="button1" onclick="aFunction($(this).parent().attr('record'))">Do a function</button>
</td>

Are there any issues (besides those of security) with this approach of storing identification variables in the HTML attributes of a table row?

like image 375
esqew Avatar asked Dec 17 '22 08:12

esqew


1 Answers

The W3C endorsed way to accomplish this is through HTML5 data- attributes...

And from a security stand point, if this data is simply the id of the record in the DB...

You shouldn't be relying on the obscurity of your ids as a security measure.

As long as you have taken proper access control security measures, it should not, a security risk, be.

like image 63
jondavidjohn Avatar answered Dec 28 '22 05:12

jondavidjohn