I have this PHP code, which is a simply login system.
<?php
session_start();
// Connecting to DB
mysql_connect("localhost", "database1", "dbdb1");
mysql_select_db("dbdb");
// Getting session info and params AFTER sending POST params
print_r($_SESSION);
function doLogin($username_post, $password_post){
$select_login = "
SELECT
id,
username
FROM
users
WHERE
username = '$username_post'
password = '$password_post'
LIMIT 1";
$query_login = mysql_query($select_login);
$rows_login = mysql_num_rows($query_login);
$array = mysql_fetch_assoc($query_login);
if($rows_login>0){
$_SESSION['user_in'] = True;
return True;
}else{
return False;
}
}
// LOGIN
$username = $_POST['username'];
$password = $_POST['password'];
if(!empty($username) && !empty($password)){
doLogin($username, $password);
}
?>
<!DOCTYPE HTML>
<html>
<body>
<form action = "" method = "post">
<input type = "text" name = "username"/>
<input type = "password" name = "password" />
<button type="submit" name = "submit">Login</button>
</form>
</body>
</html>
Appearently, it works. This code works great in local mode, but when I execute on server mode, I have a serious problem, it simply doesn't works. If you see, I put a print_r(); inside the code, I placed that, in order to know if session were succefully send. In local mode, I can see the sent params, just after reload. In server mode, I can't see it, it seems like session weren't sent.
Any suggestions? What is really happening with this code? I need to know why it works on local mode but not on server.
PHP SESSION:
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn Off Off
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly Off Off
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 5 5
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /var/lib/php/session /var/lib/php/session
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies On On
session.use_trans_sid 0 0