Reputation: 279
I want to create a folder on my server named after the current date. My variable would be: $foldername = date('HisYmd');
I have two scripts that both upload one file to the folder, one of the scripts creates the folder when the submit button is pressed, the other script uploads bigger files so it's like 5 seconds slower.
So basically my question is, how can I lock $foldername
for the two scripts so that it doesn't change every second?
Upvotes: 0
Views: 153
Reputation: 3070
Use session variables.
Example:
in file 1:
if(!session_id())
session_start();
$_SESSION['foldername'] = $foldername = date('HisYmd');
in file 2:
if(!session_id())
session_start();
if(isset($_SESSION['foldername']) && !empty($_SESSION['foldername']))
$foldername = $_SESSION['foldername'];
Upvotes: 2