oke' Below is my code
login.php
<?php
include("config.php");
if($_POST['login']) {
$us = stripslashes($_POST['username']);
$pw = stripslashes($_POST['passwd']);
$us = mysql_real_escape_string($us);
$pw = mysql_real_escape_string($pw);
$loginsql="SELECT * FROM `members` WHERE username='$us' and password='$pw'";
$result=mysql_query($loginsql) or die(mysql_error());
$count=mysql_num_rows($result);
if($count==1){
session_start(); //session starting only if correct login
setcookie("user", "$us",time()+3600);
$_SESSION['mysession'] = 1;
header("location:index.php"); //redirect after setting cookie & session
}
else {
$_SESSION['mysession'] = 0;
$wrong = "<p align=\"center\">Wrong Username or Password!</p>";
}
}
?>
it does redirect to index.php on correct login
here is the codes for index.php
<?php
ob_start();
session_start();
print_r($_SESSION);
print_r($_COOKIE);
ob_end_flush();
?>
Assuming that username is admin... it returns
Array ( ) Array ( [user] => admin [PHPSESSID] => e94cb1fb49accb88a32416e21b208417 )
When i test this on localhost it works nice! but, the problem occurs when it is used on a remote host. its a subdomain.. . . blabla.maindomain.com
Any sollution?..