php - How To Start Multiple Session
Get the solution ↓↓↓Hye, I've been creating this Quiz System, and I found myself in an error...The error started when I tried to add a DDOS Protection...Both start.php and configs.php started a session..and if the include function called start.php first, then it will only run start.php session and ignored the configs.php and vice versa. My question is how do i start both session at the same time so my website can work properly? Take a look at my code.
This is configs.php
P/S : I cut of some code to keep it short
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 'On');
function rewrite_urls($change){
$match = [
'/userdetails.php\?id=([0-9]+)/',
'/userdetails.php/',
'/plans.php/',
'/statistics.php\?id=([0-9]+)&t=([A-Za-z0-9_-]+)/',
'/quizzes.php\?request=my/',
'/quizzes.php\?id=([0-9]+)&t=([A-Za-z0-9_-]+)&request=results&r=([0-9]+)/',
'/quizzes.php\?id=([0-9]+)&t=([A-Za-z0-9_-]+)&request=results/',
'/quizzes.php\?id=([0-9]+)&t=([A-Za-z0-9_-]+)/',
'/quizzes.php\?c=([0-9]+)\&t=([A-Za-z0-9_-]+)\&page=([0-9]+)/',
'/quizzes.php\?c=([0-9]+)\&t=([A-Za-z0-9_-]+)/',
'/quizzes.php\?page=([0-9]+)/',
'/quizzes.php/',
This is my start.php
P/S : I cut of some code to keep it short
<?php
/**
* AntiDDOS System
* FILE: index.php
* By Sanix Darker
*/
function safe_print($value){
$value .= "";
return strlen($value) > 1 && (strpos($value, "0") !== false) ? ltrim($value, "0") : (strlen($value) == 0 ? "0" : $value);
}
if(!isset($_SESSION)){
session_start();
}
if(isset($_SESSION['standby'])){
// There is all your configuration
$_SESSION['standby'] = $_SESSION['standby']+1;
$ad_ddos_query = 5;// number of requests per second to detect DDOS attacks
$ad_check_file = 'check.txt';// file to write the current state during the monitoring
$ad_all_file = 'all_ip.txt';// temporary file
$ad_black_file = 'black_ip.txt';// will be entered into a zombie machine ip
$ad_white_file = 'white_ip.txt';// ip logged visitors
$ad_temp_file = 'ad_temp_file.txt';// ip logged visitors
$ad_dir = 'anti_ddos/files';// directory with scripts
$ad_num_query = 0;// current number of requests per second from a file $check_file
$ad_sec_query = 0;// second from a file $check_file
$ad_end_defense = 0;// end while protecting the file $check_file
$ad_sec = date("s");// current second
$ad_date = date("is");// current time
$ad_defense_time = 100;// ddos attack detection time in seconds at which stops monitoring
I also have head.php which will be called in every page
This is the code for head.php
<?php
try{
if (!file_exists('anti_ddos/start.php'))
throw new Exception ('anti_ddos/start.php does not exist');
else
require_once('anti_ddos/start.php');
}
//CATCH the exception if something goes wrong.
catch (Exception $ex) {
echo '<div style="padding:10px;color:white;position:fixed;top:0;left:0;width:100%;background:black;text-align:center;">'.
'The <a href="https://github.com/sanix-darker/antiddos-system" target="_blank">"AntiDDOS System"</a> failed to load '.
'properly on this Web Site, please de-comment the \'catch Exception\' to see what happening!</div>';
//Print out the exception message.
//echo $ex->getMessage();
}
include __DIR__."/configs.php";
?>
Any Idea?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to undefined function mysqli_connect()
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.