almightyegg Posted February 10, 2007 Share Posted February 10, 2007 on my site you login to mysite.co.uk then you can go to forum.mysite.co.uk but when Firefox goes there is shows a problem page I coded <? session_start(); // Session Start include 'db.php'; // Connect to DB $email = $_COOKIE['email']; $password = $_COOKIE['password']; if((!$email) || (!$password)){ echo "<html><head><link rel='stylesheet' href='default.css'><title>PROBLEMS!</title></head><body>Please enter ALL of the information! <br /></body></html>"; // THIS IS THE PROBLEM PAGE IT SHOWS! include 'http://www.koggdesigns.co.uk/index.php'; exit(); }else{ $sql = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password'"); $login_check = mysql_num_rows($sql); if($login_check == 0){ echo"<html><head><link rel='stylesheet' href='default.css'><title>PROBLEMS!</title></head><body>There were errors logging in. <a href=http://www.koggdesigns.co.uk/index.phphttp://www.koggdesigns.co.uk/index.php>Try again!</a></body></html>"; exit(); }else{ // page here } ?> the page before starts like this: session_start(); // Session Start include 'db.php'; // Connect to DB $email = $_POST['email']; $password = $_POST['password']; setcookie(email, $email); setcookie(password, $password); Why can't FF work this but IE can Quote Link to comment https://forums.phpfreaks.com/topic/37937-solved-firefox-and-cookies/ Share on other sites More sharing options...
wildteen88 Posted February 11, 2007 Share Posted February 11, 2007 if you want your site cookies to work across subdomains you need to setup the cookie completely, the following should do: setcookie('email' $email, time+3600, '/', '.mysite.com') That will tell the browser to set a cookie called email with the value of $email, expire the cookie after an hour. Allow the cookie to be accessed site-wide and be used in sub-domains. Also make sure the browser is accepting cookies - very important that. Also session_start(); is not needed in your code as you appear to not be using sessions. Only cookies - which are not sessions. Quote Link to comment https://forums.phpfreaks.com/topic/37937-solved-firefox-and-cookies/#findComment-181868 Share on other sites More sharing options...
almightyegg Posted February 11, 2007 Author Share Posted February 11, 2007 I did that and now it shows the same thing in IE and FF as it did in just FF before... EDIT: Also, the session start is there because I used to use sessions but found cookies a better way for a user site Quote Link to comment https://forums.phpfreaks.com/topic/37937-solved-firefox-and-cookies/#findComment-181885 Share on other sites More sharing options...
almightyegg Posted February 11, 2007 Author Share Posted February 11, 2007 Current Cookies // first login page: setcookie(email, $email, time+3600, '/', '.koggdesigns.co.uk'); setcookie(password, $password, time+3600, '/', '.koggdesigns.co.uk'); // ALL other pages mysite.co.uk/pages.php AND subdomain.mysite.co.uk/pages.php $email = $_COOKIE['email']; $password = $_COOKIE['password']; Quote Link to comment https://forums.phpfreaks.com/topic/37937-solved-firefox-and-cookies/#findComment-181939 Share on other sites More sharing options...
wildteen88 Posted February 11, 2007 Share Posted February 11, 2007 Current Cookies // first login page: setcookie(email, $email, time+3600, '/', '.koggdesigns.co.uk'); setcookie(password, $password, time+3600, '/', '.koggdesigns.co.uk'); // ALL other pages mysite.co.uk/pages.php AND subdomain.mysite.co.uk/pages.php $email = $_COOKIE['email']; $password = $_COOKIE['password']; EDITED Do you still have a problem with the code? I notice in your code when you set the cookie you don't wrap the cookie name (first parameter for set_cookie) in quotes. You should wrap all strings in quotes unless you are using a constant. If you are using constants then they should be in uppercase (MYCONST). Also did a slight boobo with the code it should be this: // first login page: setcookie('email', $email, time()+3600, '/', '.koggdesigns.co.uk'); setcookie('password', $password, time()+3600, '/', '.koggdesigns.co.uk'); I forgot to add the () after time. So the cookies where invalid and thus it didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/37937-solved-firefox-and-cookies/#findComment-182099 Share on other sites More sharing options...
almightyegg Posted February 11, 2007 Author Share Posted February 11, 2007 great that works! Could I do time()+any number??? I would like it to last for 24 hours so could I just put in time()+86400? Quote Link to comment https://forums.phpfreaks.com/topic/37937-solved-firefox-and-cookies/#findComment-182114 Share on other sites More sharing options...
wildteen88 Posted February 11, 2007 Share Posted February 11, 2007 Yes you can. Note the number must in secound. So 1 hour = 3600. if you want the cookie to expire after a week for example, then do this: time()+3600*24*7 3600 (1 hour) x 24 (24 hours = 1 day). Then times that by 7 to get the seconds in a week (7 days in a week). Its just basic maths Quote Link to comment https://forums.phpfreaks.com/topic/37937-solved-firefox-and-cookies/#findComment-182122 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.