How to store information in php without database? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to store information in php without database?

Hi SLs, i need little help from you all. i am creating a web app without help of database. all the files are in php, css ,js ,html only. i am using recaptcha for a commenting page. To store api keys , previously i was using config.php where i was storing api keys as variable like $pub_key = "key"; $priv_key = "key"; In my app i am trying to create a admin panel to ease out this for my app users. To edit keys, directly from admin panel is looking little difficult. Please provide me some help for this prob.

31st Mar 2018, 5:57 AM
Aditya
Aditya - avatar
3 Answers
+ 6
The supposed answer to your solution is localStorage()... It's Javascript dependent and definitely not a perfect solution, but HTML5 localStorage allows you to store preferences on your users' computers. First, detect support for localStorage(): if (Modernizr.localstorage) { // with Modernizr if (typeof(localStorage) != 'undefined' ) { // Without Modernizr Then set a parameter if it's supported: localStorage.setItem("somePreference", "Some Value"); And then later retrieve it, as long as your user hasn't cleared local storage out: var somePreference = localStorage.getItem("somePreference"); When you want to clear it, just use: localStorage.removeItem("somePreference"); For those using unsupported (older) browsers, you can use local storage hacks abusing Flash LSOs, but those are definitely not ideal. What about sessions or cookies? Both of these are intentionally temporary forms of storage. Even Flash LSOs are better than cookies for long-term storage. The constraint is literally encouraging poor practices... All of these options are browser-side. If the user moves to another PC, his/her preferences will be reset on that PC, unlike with a database-powered authentication system where you can save preferences against a login. The best way to store this kind of data is in a database. If you can't run a database service, you could use SQLite or store the data in JSON or XML files.
31st Mar 2018, 7:17 AM
Baraa AB
Baraa AB - avatar
+ 1
I also tried to store api keys in separate file. with a file extension .dat but there is problem, .dat was showing keys in problem. I am looking for more secure way to store such information like api keys, passwords, etc without help of database.
31st Mar 2018, 5:59 AM
Aditya
Aditya - avatar
0
I am looking to store information on web server not on user's browser
31st Mar 2018, 2:14 PM
Aditya
Aditya - avatar