Jump to content

sessions not sticking in safari


dadamssg

Recommended Posts

i've got a login system and various pages...all with session_start() at the top of each, but it seems like every time i log in in safari then click on the next page my session variables don't stick and im logged out, i login again...then it sticks throughout the same pages....has anyone had any trouble with this, and come to any solutions? thanks

Link to comment
https://forums.phpfreaks.com/topic/152904-sessions-not-sticking-in-safari/
Share on other sites

k its not just with safari...scratch that

well heres of the top of my three scripts involved

top of my homepage

<?php 
session_start(); 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> Home</title>
<link rel="stylesheet" type="text/css" href="new.css" />
<style type:"text/css">
body {
margin:0;
padding: 0;
background-color: white ;
background-image: url(stripe.png) ;
background-repeat: repeat-xy;

}

<?php
include("caneck.inc");
include("sdateselectfun.php");
include("edateselectfun.php");
include("timeselectfuncs.php");
include("loginfunc.php");
?>

</style>
</head>

<body>

   <!-- Begin Wrapper -->
   <div id="wrapper">
   
         <!-- Begin Header -->
         <div id="header">
<?php
$name = ucword($_SESSION['logname']);
echo"<div id='howdy'>";
	 if (@$_SESSION['auth'] != "yes")
           {
            
           }
	  else 
              {
               echo "Howdy" .$name;
              }	
echo"</div>";
		  
echo"<div id='date'>";
$hr = (int) date("H")+5;
$mi = (int)  date("i");
$mo = (int) date("n");
$da = (int) date("j");
$yr = (int) date("Y"); 
$rnow = gmmktime( $hr,$mi,0,$mo,$da,$yr);///aggieland time is now
echo date('F j, Y    g:i a',$rnow);
echo"</div>";			  
?>  

 

all of my login script--minus my domain names in the headers

<?php
session_start();                                      
include("caneck.inc");                                  

     $cxn = mysqli_connect($host, $user,$passwd,$dbname) 
            or die ("Couldn't connect to server.");    

$password = mysqli_real_escape_string($cxn, strip_tags($_POST['fpassword']));
$username = mysqli_real_escape_string($cxn, strip_tags($_POST['fusername']));

     $sql = "SELECT loginName FROM Member 
             WHERE loginName='$username'";     
     $result = mysqli_query($cxn,$sql)
               or die(mysqli_error($cxn));      
     $num = mysqli_num_rows($result);                  
     if ($num > 0)  // login name was found            
     {
        $sql = "SELECT loginName,active FROM Member 
                WHERE loginName='$username'
                AND password=md5('$password')";
        $result2 = mysqli_query($cxn,$sql)
                   or die(mysqli_error($cxn));
        $num2 = mysqli_num_rows($result2);
	$row = mysqli_fetch_assoc($result2);
        if ($num2 > 0)  // password is correct         
        {
	    if($row['active']=="8"){
           $_SESSION['auth']="yes";                    
           $logname=$username; 
           $_SESSION['logname'] = ucwords($logname);                       
           header("Location: /test/project12.php"); 
           }
           else{Header("Location: http://www..com/test/checkmail.php");}		   
        }
        else    // password is not correct             
        {
                     
	   Header("Location: http://www..com/test/register_form.php");
        } 
     }                                                
     elseif ($num == 0)  // login name not found       
     {   
        
       
	 Header("Location: http://www..com/test/register_form.php");
     }
 else
 {
 Header("Location: http://www..com/test/register_form.php");
 }
                                           
?>

and then the top that gets logged out when i go to it the first time...if i log in again and go to it...my sessions stick

<?php
session_start();
$postid = $_GET["id"];

if (! ctype_digit($postid)) {
        header("Location: http://www..com");
    }

 include("caneck.inc");
   
   $postid = $_GET["id"];

$cxn = mysqli_connect($host,$user,$passwd,$dbname)
          or die ("Couldn't connect");
//get event	  
$quer = "SELECT * FROM test WHERE eventid = $postid";

$rsult = mysqli_query($cxn,$quer)
          or die ("Couldn't execute");
		  				  
	$found = mysqli_num_rows($rsult); //check if postid exist, if not send to homepage
	if ($found > 0)
	 {}
	 else
	{header("Location: http://www..com");}

$row = mysqli_fetch_assoc($rsult);

//get replies
$quu = "SELECT * FROM Replies WHERE postid = $postid ORDER BY time ASC";
$res = mysqli_query($cxn,$quu)
            or die ("Couldn't execute");




?>

i also have this in this last page

if (@$_SESSION['auth'] != "yes")
           {
            echo "<div id= 'login'>
                   <form action='login.php' method='POST'>
                   <fieldset>
                       Username: <br><input type='text' name='fusername' 
                      size='15' maxlength='15'><br>
                       Password: <br><input type='password' name='fpassword' 
                      size='15' maxlength='15'><br>
				  <a href=/test/register_form.php>Register</a><br>
                   <input type='hidden' name='do' 
                                     value='login'>
           
                <center><input type='submit' name='log' 
                             value='Login'></center>
	      </fieldset>
                      </form></div><br>";
           }


]if(isset($_SESSION['logname'], $_SESSION['auth']) && $_SESSION['auth'] =="yes")
   {
        echo "<center><form action='reply_form.php?id={$postid}' method='POST'>
        <input type='submit' name='do' value='Reply'>
         </form></center>";
}
echo "<br><br>";
if($_SESSION['logname'] == $row['createdby'])
{
echo "<center><form action='update_form.php?id={$postid}' method='POST'>
        <input type='submit' name='do' value='Update'>
         </form></center>";
}

 

thanks for lookin at it

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.