Skip to content

Commit

Permalink
Fixing notices on session_start(), when sesion is already started
Browse files Browse the repository at this point in the history
  • Loading branch information
Seitanas committed Sep 8, 2016
1 parent 8f5d104 commit 72750c9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 4 additions & 2 deletions client_pools.php
Expand Up @@ -23,7 +23,8 @@
$sql_reply=get_SQL_line("SELECT id,password FROM clients WHERE username LIKE '$username' AND isdomain=0");
if(!empty($sql_reply[1])){
if (password_verify($password, $sql_reply[1])){
session_start();
if (session_status() == PHP_SESSION_NONE)
session_start();
$_SESSION['client_logged']='yes';
$_SESSION['userid']=$sql_reply[0];
$_SESSION['username']=$username;
Expand Down Expand Up @@ -88,7 +89,8 @@
$ip = $_SERVER['REMOTE_ADDR'];
add_SQL_line("INSERT INTO clients (username,ip,isdomain,lastlogin) VALUES ('$query_user','$ip','1',NOW()) ON DUPLICATE KEY UPDATE ip='$ip', lastlogin=NOW()");
$sql_reply=get_SQL_line("SELECT id FROM clients WHERE username LIKE '$query_user'");
session_start();
if (session_status() == PHP_SESSION_NONE)
session_start();
$_SESSION['ad_user']='yes';
$_SESSION['client_logged']='yes';
$_SESSION['userid']=$sql_reply[0];
Expand Down
12 changes: 7 additions & 5 deletions functions/functions.php
Expand Up @@ -2,7 +2,7 @@
/*
KVM-VDI
Tadas Ustinavičius
2016-09-01
2016-09-08
Vilnius, Lithuania.
*/
function SQL_connect(){
Expand Down Expand Up @@ -98,23 +98,25 @@ function reload_vm_info(){
}
//##############################################################################
function check_session(){
session_start();
if (session_status() == PHP_SESSION_NONE)
session_start();
if (isset($_SESSION['logged']))
return $_SESSION['logged'];
else return 0;
}
//##############################################################################
function check_client_session(){
session_start();
if (session_status() == PHP_SESSION_NONE)
session_start();
if ($_SESSION['client_logged'])
return $_SESSION['client_logged'];
else return 0;
}
//##############################################################################
function close_session(){
session_start();
if (session_status() == PHP_SESSION_NONE)
session_start();
$_SESSION['logged']='';
// session_unset();

}
//##############################################################################
Expand Down
3 changes: 2 additions & 1 deletion login.php
Expand Up @@ -6,7 +6,8 @@
$password=$_POST['password'];
$sql_reply=get_SQL_line("SELECT id,password FROM users WHERE username LIKE '$username'");
if (password_verify($password, $sql_reply[1])){
session_start();
if (session_status() == PHP_SESSION_NONE)
session_start();
$_SESSION['logged']='yes';
$_SESSION['userid']=$sql_reply[0];
$ip = $_SERVER['REMOTE_ADDR'];
Expand Down
3 changes: 2 additions & 1 deletion logout.php
Expand Up @@ -3,7 +3,8 @@
require_once("functions/functions.php");
if (isset($_GET['type'])){
if($_GET['type']=='client'){
session_start();
if (session_status() == PHP_SESSION_NONE)
session_start();
$_SESSION['client_logged']='';
header("Location: $serviceurl/client_index.php");
exit;
Expand Down

0 comments on commit 72750c9

Please sign in to comment.