From: Barry Zimmerman on 13 May 2010 07:32 Safari browser will not accept my cookie it is ignoring it? have I done something wrong with how the cookie is presented for safari??? The cookie I try to set: setcookie('peg', 'YES', 'time()+190', '', 0); Also all browsers are starting my phpsession off when its not even declared until after the post request? Can someone please help and tell me why my session is getting set, as when I go to the page I can see that the php session is being set as I check the cookies it has the phpsession there? Totally puzzled? Here is my code <? // Include the connections script to make a database connection. include("inc/connect.php"); $username = ""; $password = ""; $errorMessage = ""; function quote_smart($value, $handle) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } if (!is_numeric($value)) { $value = "'" . mysql_real_escape_string($value, $handle) . "'"; } return $value; } if ($_SERVER['REQUEST_METHOD'] == 'POST'){ $username = $_POST['username']; $password = $_POST['password']; $username = htmlspecialchars($username); $password = htmlspecialchars($password); $db_found = mysql_select_db($db, $connection); if ($db_found) { $username = quote_smart($username, $connection); $password = quote_smart($password, $connection); $SQL = "SELECT * FROM tablea WHERE username = $username AND password = '".md5($_POST['password'])."'"; $result = mysql_query($SQL); $num_rows = mysql_num_rows($result); if ($result) { if ($num_rows > 0) { session_start(); $_SESSION['username'] = "$_POST[username]"; header ("Location: index.html"); } /* New Block Log in attempts*/ else { session_start(); $_SESSION['attempts'] = "+1"; # setup SQL statement $SQL = " INSERT INTO tableb "; $SQL = $SQL . " (sid, username, password, attempts, ipaddress) VALUES "; $SQL = $SQL . " ('$_COOKIE[PHPSESSID]', '$_POST[username]', '$_POST[password]', '$_SESSION[attempts]', '$_SERVER[REMOTE_ADDR]') "; #execute SQL statement $result = mysql_db_query( *****,"$SQL",$connection ); # check for error if (!$result) { echo("ERROR: " .. mysql_error() . "\n$SQL\n"); } else { # setup SQL statement 2 $SQL = "SELECT * FROM tableb WHERE sid = '$_COOKIE[PHPSESSID]' "; $result = mysql_query($SQL); if (mysql_num_rows($result) ==0) { $errorMessage = "Please check your username and/or password is correct"; } elseif (mysql_num_rows($result) >=3) { header ("Location: index2.html"); } else { $errorMessage = "Please check your username and/or password is correct"; } } } /* END */ } else { $errorMessage = "Please check your username and/or password is correct"; } mysql_close($connection); } else { $errorMessage = "Please check your username and/or password is correct"; } } ?>
From: Barry Zimmerman on 13 May 2010 08:21 Its only happening in safari with the cookie not being set. It must be my cookie string that is the problem. I just cannot find anything on the issue. My other major issue is the fact that the session is being set when the post has not even been declared, its just setting the session?
From: Chaitanya Yanamadala on 13 May 2010 09:07 On 5/13/10, Barry Zimmerman <barryzimmo(a)googlemail.com> wrote: > Its only happening in safari with the cookie not being set. It must be my > cookie string that is the problem. I just cannot find anything on the issue. > > My other major issue is the fact that the session is being set when the post > has not even been declared, its just setting the session? > Hai I think it is a problem with the safari And also check whether u r sending any html tags before ur sending the cookies. The other case could be with ur browser Goto preferences ->security->accept cookies in d browser and check the button always and then exit browser Now check that Regarding ur second problem session starting before posting the vales it is might be coz of the old session that is existing whenu ran last time so do some thing like delete all cookies and sessions from the browser and try also make sure that u dont have a session start in the database connection php file -- Chaitanya "A man can get discouraged many times but he is not a failure until he stops trying..." "The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'."
From: Richard Quadling on 13 May 2010 09:26 On 13 May 2010 12:32, Barry Zimmerman <barryzimmo(a)googlemail.com> wrote: > setcookie('peg', 'YES', 'time()+190', '', 0); Can you try removing the quotes from around the expire parameter. setcookie('peg', 'YES', time()+190, '', 0); Richard -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling
|
Pages: 1 Prev: Extending my login - not sure how to add my code block in Next: Session start |