Thew
Thew

Reputation: 15959

Best way to store 1 variable server-side

I want to store just 1 PHP variable, with only 2 options, Yes or No. But im was thinking, whats the best way to do this? Is the best way to use a MySQL Database? A file? What?

A TXT file was recommanded here, but how can i use that properly? What CHMod? Is it safe?

Upvotes: 1

Views: 1425

Answers (2)

prajwal GN
prajwal GN

Reputation: 9

Since it is server side better to use Sessions

<?php
session_start();
//for yes
if(yes){
$_SESSION['flag']=1;
}
.
.
.
.
//While using that sessions
if(isset($_SESSIONS,'flag')){
  //t
}
else{
}

Upvotes: -1

Kaken Bok
Kaken Bok

Reputation: 3395

Since "Yes or No" can be converted to "1 or 0" or "has or not has", you could simply add a file. If it exists, it means "YES". If not, it means "NO".

Random link: http://en.wikipedia.org/wiki/File_locking#Lock_files

Upvotes: 2

Related Questions