Jump to content

Recommended Posts

I'm not really sure if this is a cookie problem but that's all I could think of. I have a web site that users have to log into. I have seen that when I log out of my account and log into my test account my main user name will still show on the welcome page unless I let the computer sit for a bit or if I clear recent history. This happens in all the main browsers. I have also started having a problem where if I update something in my database it shows up in MySQL right away but can take a while to show up on the web page unless i clear the history. Not sure what code to post to give you an idea so if you want to see something let me know and I will put it up.

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/257567-cookie-probloms/
Share on other sites

This is my log in scrip

include"scripts/connect.php" ;


mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$encrypted_password=md5($mypassword);

$sql="SELECT * FROM user WHERE username='$myusername' and password='$encrypted_password' and active=1";
$result=mysql_query($sql);


$count=mysql_num_rows($result);
$row = mysql_fetch_assoc($result);
    $rank = $row['rank'];
$loggedinusername = $row['username'];
$loggedinuseremail = $row['email'];

if($count==1){
session_start();
$_SESSION['login'] = "1"; 
$_SESSION['rank'] = $rank;
$_SESSION['loggedinusername'] = $loggedinusername;
$_SESSION['loggedinuseremail'] = $loggedinuseremail;
header ("Location:index.php");
} else { 
$errorMessage = "Invalid Login"; 
session_start(); 
$_SESSION['login'] = '';
header ("Location:login.php");
} 

 

and this is my session

session_start(); 
   
if(!$_SESSION['login']){
$_SESSION['rank'];
$_SESSION['loggedinusername'] = $loggedinusername;
$_SESSION['loggedinuseremail'] = $loggedinuseremail;
header("location:login.php");
}
$rank=$_SESSION['rank'];
$loggedinusername=$_SESSION['loggedinusername'];
$loggedinuseremail=$_SESSION['loggedinuseremail'];

Link to comment
https://forums.phpfreaks.com/topic/257567-cookie-probloms/#findComment-1320176
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.