Binary Accepted
Binary Accepted

Reputation: 49

Storing variables for long periods

It's been a very long time since I've been on here so I hope I'm doing this properly.

I'm working on a web project that is basically a twitch streamer's profile type of site. It's being designed to display only that streamers information about their stream. So no other users should be logging in via twitch or otherwise.

The problem I'm having is the recent changes to the twitch API requires OAuth to be utilized and the token resets after a period of time as it should.

The question really is this..

How would I go about privately storing a variable on the site? This variable would need to last around 30 - 60 days, not be stored anywhere other than the server, be inaccessible to anyone, and can be changed easily after the time period is up.

I was looking through APC and realized since I'm using php 7.2 that its been replaced with APCU. Reviewing details on APCU there would be problems with that information not being stored for the time frame I need and could possibly just up and get cleared. So that marked that out.

I thought about local file storage but I need to keep the information I'm gathering secret so local file is a nope.

I intend to release the source code once the project is finished so I don't want to use databases as it just makes it more complicated for the simplistic user.

sessions are stored as cookies and that puts the string in the hands of whoever might want to be malicious so thats a nope.

Long story short I'm trying to avoid the following.

local file storage
databases
sessions
any kind of caching that would be unreliable

I just need a step in the right direction.

Sorry about the lengthy post.

Upvotes: 0

Views: 89

Answers (2)

Binary Accepted
Binary Accepted

Reputation: 49

I believe I found the solution to the problem. I can still utilize files for the storage and if I place a .htaccess to the directory I wish to restrict with deny from all the server can still access the files and read them accordingly while at the same time restricting outside intrusion.

A little more trickery with some .htaccess and I can just send a 404 response so it looks like there's nothing special there instead of alerting anyone of the files or directories presence.

Thanks to SystemGlitch and imvain2 for making me think more on that problem so I could realize the solution possibilities.

Upvotes: 0

SystemGlitch
SystemGlitch

Reputation: 2262

If you want minimal setup and infrastructure, sqlite can be a good option. It's still a database but it works within PHP directly and only requires a file to store the data in. This solution is very often used in mobile apps as well so developers can benefit from the power of SQL while keeping it simple for the user.

sqlitetutorial.net has good tutorials to get your started.

Upvotes: 1

Related Questions