PHP - In Ie My Session Cookies Are Mysteriously Deleted.
I'm pulling my hair out here...
Here's my problem. I'm about halfway done with my site (It's a site to sell stuff and I'm working on the shopping cart) when I noticed a big problem. I've got session cookies working in every browser (FF, chrome, safari) except Internet Explorer. For some reason IE likes to delete my session cookies so there's nothing there after I click 'view shopping cart'. I've verified that the session is set but then it gets deleted. Now I am using IFrames and I searched for possible causes and tried changing headers, making sure there's no underscores, etc... No joy The problem is that getting the problem to show up would require a lot of copying code onto this page since it's like 4 or 5 pages to get something into the cart and then view the cart itself. What do you folks recommend? Should I just link to the site itself? Similar TutorialsHello all..... Grasshopper here......... Need help with the following: I have a registration form for a Sport Gym Complex offering a free guest pass if you register...... Where would I implement cookies or sessions to reject 2nd times registrants trying to take advantage of the free guest pass within the year; I have attached the php.file Thanks Steve Ok guys heres the deal. I have been struggling on this for about two weeks and am giving up. Because I'm giving up, I would like to throw this up to you guys to help me out. I am trying to build a login I tried learning sessions but they make no sense to me whatsoever on how the information passes from one to another. So i created my own sessions database, where im uploading the data i need to pass page to page to my db, and repulling it on the next page. In order to do this i needed to create a cookie so I can refrence that data on the next page, main.php. When I run main.php i get an the echo of. "THIS COOKIE AINT FUCKING WORKING". which to me means one of two things. One is either im not creating the cookie right, or two, im not accessing it correctly. But to widdle that down I created the testpoint on if cookie is created and it seems to work fine, cuase im not getting the die(). Im not an advance php programmer by any means, just been self learning for a few months, so bear with me and please break it down as much as possible. I feel that if i can just get a userid created on one page, put it into a cookie, send it, and retreive it when on the next page, i can do the rest from there. If you can see why that is happening then let me know. Thanks in advance. NEVERBEGOSU ---------------------------------- index.php ------------- Code: [Select] <?php include ('srvdbcon.php'); include ('functions/sitebuild.php'); include ('functions/functions.php'); setcookie('user', 'mike'); login(); headcontent(); headermain(); leftcontent(); ?> <div id="content"> <div class="post"> <h1 class="title"><a href="#">Welcome to </a></h1><p class="byline">21 April 2011 by <a href="#"></a></p> <div class="entry"> <p><strong></strong> is a free, 100% Starcraft 2 Replay Center. Our goal is to provide the ability to UPLOAD replays with detailed data, as well as to DOWNLOAD those replays. Our Replay Search function is one of a kind, designed by hand to help you find replays that you are looking for.</p> <p class="links"><a href="#" class="more">About Us</a></p> </div> </div> <div class="post"> <h2 class="title"><a href="#">Latest News</a></h2> <p class="byline">Working hard to get the site up and running. <a href="#"></a></p> <div class="entry"> <h3>Looking for late May Release:</h3> <blockquote> <p>Im working really hard guys. Forgive me for the pushback.</p> </blockquote> <h3>In Production:</h3> <ul> <li>Working on a new template for the site.</li> <li>Continuing developing the search function for replays.</li> <li>In the middle of moving in RL so working hard when I can.</li> <li>Working hard on the member login/registration pages.</li> <li>Started working on the forums</li> </ul> <h3>Finished:</h3> <ul> <li>Got the Upload Page working.</li> <li>Completed the Download style for the site.</li> <li>Finished a few other smaller aspects.</li> </ul> <p class="links"><a href="#" class="more">Read More</a></p> </div> </div> <div class="post"> <h2 class="title"><a href="#">LOOKING FOR HELP </a></h2> <p class="byline"><small>Posted on 22 Aprl 2011 by <a href="#">SCG.Admin</a></small></p> <div class="entry"> <p> is looking for a few people, if willig, to help design the site. The following positions are needed. </p> <ul> <li>Graphics Designer</li> <li>PHP/MYSQL Programmer</li> </ul> <p>If anyone is intrested please contact me at .</p> <p class="links"><a href="#" class="more">Read More</a></p> </div> </div> </div> <?php rightcontent1(); echo "<center><h2>Login</h2></center> "; echo "<form name='log' method='POST' action='" . $PHP_SELF . "'>"; echo "Username:"; echo "<p><input type='text' name='username'>"; echo "<p>Password:"; echo "<p><input type='password' name='password'>"; echo "<p><input type='submit' id='log' name='log' value='Login'>"; echo "<br>"; echo "<h2> Not a Member </h2>"; echo "<p><a href='register.php'>Register</a></p>"; echo "</center>"; rightcontent2(); footerdiv(); ?> ------------------------------------------------------------------------------------------- main.php --------- Code: [Select] <?php include ('srvdbcon.php'); include ('functions/sitebuild.php'); if(!isset($_COOKIE['userid'])); { die ('CANT GET THE FUKCING COOKIE TO WORK'); } headcontent(); headermain(); leftcontent(); ?> <div id="content"> <div class="post"> <h1 class="title"><a href="#">Welcome to </a></h1><p class="byline">21 April 2011 by <a href="#">SCG.Admin</a></p> <div class="entry"> <p><strong></strong> is a free, 100% Starcraft 2 Replay Center. Our goal is to provide the ability to UPLOAD replays with detailed data, as well as to DOWNLOAD those replays. Our Replay Search function is one of a kind, designed by hand to help you find replays that you are looking for.</p> <p class="links"><a href="#" class="more">About Us</a></p> </div> </div> <div class="post"> <h2 class="title"><a href="#">Latest News</a></h2> <p class="byline">Working hard to get the site up and running. <a href="#">SCG.Admin</a></p> <div class="entry"> <h3>Looking for late May Release:</h3> <blockquote> <p>Im working really hard guys. Forgive me for the pushback.</p> </blockquote> <h3>In Production:</h3> <ul> <li>Working on a new template for the site.</li> <li>Continuing developing the search function for replays.</li> <li>In the middle of moving in RL so working hard when I can.</li> <li>Working hard on the member login/registration pages.</li> <li>Started working on the forums</li> </ul> <h3>Finished:</h3> <ul> <li>Got the Upload Page working.</li> <li>Completed the Download style for the site.</li> <li>Finished a few other smaller aspects.</li> </ul> <p class="links"><a href="#" class="more">Read More</a></p> </div> </div> <div class="post"> <h2 class="title"><a href="#">LOOKING FOR HELP </a></h2> <p class="byline"><small>Posted on 22 Aprl 2011 by <a href="#">SCG.Admin</a></small></p> <div class="entry"> <p>SCG.O is looking for a few people, if willig, to help design the site. The following positions are needed. </p> <ul> <li>Graphics Designer</li> <li>PHP/MYSQL Programmer</li> </ul> <p>If anyone is intrested please contact me at </p> <p class="links"><a href="#" class="more">Read More</a></p> </div> </div> </div> <?php rightcontent1(); rightcontent2(); footerdiv(); ?> ---------------- functions.php Code: [Select] <?php function verifylogin() { } function login() { $Login=$_POST['log']; if ($Login) { $username=$_POST['username']; $password=($_POST['password']); $verlogin="SELECT * FROM user WHERE user='$username' AND password='$password'"; $verloginq=mysql_query($verlogin); if(mysql_num_rows($verloginq)!='0') { setcookie('userid' , 'mike'); if (setcookie) { $ip = getenv("REMOTE_ADDR"); $time=time(); $loginquery="INSERT INTO login (id,user,date,ip) VALUES ('','$username','$time','$ip')"; $loginqueryr=mysql_query($loginquery); if ($loginqueryr) { header("location:testmain.php"); } else { die('There was a problem sending info to database: LOGIN.'); } } else { die ('Cookie wont set for some damn reason.');} } else {die ('username/password error');} } else { } } function logout() { } function logcook() { } function logsess() { } ?> MOD EDIT: [code] . . . [/code] BBCode tags added. Hello, I have the following code. I am trying to have it same the searches save for 30 days. I can't tell exactly how long this works for because it does work for a while but when I open the browser the following day, the information is lost. The server time is accurate. Does anyone have any clue to why this might not work? session_set_cookie_params(2592000); session_name('test_mysearches'); session_start(); $rqstsignature = md5($_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'].print_r($_POST, true));if(!isset($_SESSION['mysearches'])) { $_SESSION['mysearches'] = array($_GET['s']);} else { if ($_GET['s'] != '') { $_SESSION['mysearches'] = array_filter($_SESSION['mysearches'], 'strlen'); if ($_SESSION['LastRequest'] != $rqstsignature) { // not a refresh array_unshift($_SESSION['mysearches'], $_GET['s']); $_SESSION['LastRequest'] = $rqstsignature; while(count($_SESSION['mysearches']) > 5) { array_pop($_SESSION['mysearches']); } } } } () thanks in advance. Warning: Cannot modify header information - headers already sent by (output started at /berw/ugrad1/base/s/seh8/public_html/cs25010/index.php:3) in /berw/ugrad1/base/s/seh8/public_html/cs25010/index.php on line 4 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /berw/ugrad1/base/s/seh8/public_html/cs25010/index.php:3) in /berw/ugrad1/base/s/seh8/public_html/cs25010/index.php on line 7 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /berw/ugrad1/base/s/seh8/public_html/cs25010/index.php:3) in /berw/ugrad1/base/s/seh8/public_html/cs25010/index.php on line 7 here is the start of the code, I have do idea what is happening, help please! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?PHP setcookie('user', 'sianiuser'); ?> <?php session_start(); if (isset($_SESSION['sianiuser'])) { unset ($_SESSION['sianiuser']); } ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/> What is the best practice to use cookies and sessions? Should i create a cookie and keep inside the cookie the name of the username the user has logged in or a session? How am i supposed to compine theese two? Is there any example or a tutorial on this? For example how does php freaks sessions and cookies work. What's the best way to store shopping cart information? I want things to stay in the cart for up to 2 weeks after they're added, without the need for somebody to log-in to their account to store them. Should I store the information in a database some how and then set a cookie referencing the cart_id in the db? Hi, I'm working on a page that GETs a value that is passed in the URL. This variable echos correctly up until I try echoing it inside an if statment where it needs to be. The variable is called $siteid. Inside my if statement I have a query that runs WHERE id='$siteid' Inside this if statement it won't echo out. It is the weirdest thing. I tried to hardcode the siteid as 95, to test it, and the query updated my database as it should. However, leaving it as the variable it will not work. Any help solving this mystery that I've been banging my head over for hours would be greatly appreciated! My variable echos correctly up until the line that says: // $siteid will Echo up until here. After this point it stops working. The query I am having issues with is after the line that says: // Problem lies in this query. My SQL Table: id int(11) No userid int(11) No url varchar(2083) No credits int(11) No 0 dailyviews int(11) No 0 todayviews int(11) No 0 totalviews int(11) No active tinytext No title varchar(50) No confirmed tinytext No And my code: <?php session_start(); if (isset($_SESSION['username'])){ $loginstatus = "logout"; $username = $_SESSION['username']; include_once('inc/connect.php'); $siteid = $_GET['siteid']; $message = "messagebox"; $success = " "; $error = " "; $useridquery = "SELECT id FROM users WHERE username='$username'"; $useridresult = mysql_query($useridquery); $useridrow = mysql_fetch_assoc($useridresult); $userid = $useridrow['id']; $result1 = mysql_query("SELECT * FROM websites WHERE `id`='$siteid' && userid='$userid'"); $siterow1 = mysql_fetch_assoc($result1); $titledb = $siterow1['title']; $urldb = $siterow1['url']; $maxviewsdb = $siterow1['dailyviews']; $statusdb = $siterow1['active']; $titlenew = $_POST['title']; $urlnew = $_POST['url']; $maxviewsnew = $_POST['maxviews']; $statusnew = $_POST['status']; if($statusnew=="Active"){ $statusnew = "yes"; } else{ $statusnew = "no"; } $editnewsite = $_POST['editnewsite']; if($success!=""){ $message = ""; } else{ $message = "messagesuccess"; } // $siteid will Echo up until here. After this point it stops working. if($editnewsite){ if($titlenew){ if($urlnew){ if($maxviewsnew){ function valid_url($urlnew) { return ( ! preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $urlnew)) ? FALSE : TRUE; } if(valid_url($urlnew)){ //Check if URL is a Duplicate for current user $results = mysql_query("SELECT * FROM `websites` WHERE `userid`='$userid' AND `url`='$url'"); $rows = mysql_num_rows($results); if ($rows<=0) { $siteidnew = $siteid; // Problem lies in this query. $update = "UPDATE `websites` SET `title`='$titlenew', `url`='$urlnew', `dailyviews`='$maxviewsnew', `active`='$statusnew' WHERE `id`='$siteid' && `userid`='$userid'"; mysql_query($update); $titledb = $titlenew; $urldb = $urlnew; $maxviewsdb = $maxviewsnew; $statusdb = $statusnew; echo $titledb; echo $urldb.$maxviewsdb.$statusdb."<br>".$siteid; // PROBLEM HERE exit(); } else{ $error = "You have already submitted that site"; $message = "messageerror"; } } // here else { $error = "Invalid URL"; $message = "messageerror"; } } else{ $error = "Type in the Maximum Views you<br />want your site to get daily!"; $message = "messageerror"; } } else{ $error = "Type in the Url of your website!"; $message = "messageerror"; } } else{ $error = "Type in a Title for your site!"; $message = "messageerror"; } } } else{ $loginstatus = "login"; header("Location: index.php"); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="description" content="Free Piano Sheet Music - Sheet Music Haven" /> <meta name="keywords" content="Piano,Sheet,Music,Haven,Score,Piece,Top,Trade" /> <meta name="author" content="Sheet Music Haven" /> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" /> <title>Edit Sites - Sheet Music Haven</title> <link rel="stylesheet" type="text/css" href="styles/style.css" /> <link rel="stylesheet" type="text/css" href="styles/editsites.css" /> <script type="text/javascript"> function make_blank() { if(document.login.username.value =="Username"){ document.login.username.value =""; document.login.username.style.color ="#000000"; } } function make_blank1() { if(document.login.password.value =="Password"){ document.login.password.value =""; document.login.password.type ="password"; document.login.password.style.color ="#000000"; } } function undoBlank() { if(document.login.username.value == ""){ document.login.username.value ="Username"; document.login.username.style.color="#ccc"; } } function undoBlankpass() { if(document.login.password.value == ""){ document.login.password.value ="Username"; document.login.password.style.color="#cccccc"; } } function inputLimiter(e,allow) { var AllowableCharacters = ''; if (allow == 'NumbersOnly'){AllowableCharacters='1234567890';} var k; k=document.all?parseInt(e.keyCode): parseInt(e.which); if (k!=13 && k!=8 && k!=0){ if ((e.ctrlKey==false) && (e.altKey==false)) { return (AllowableCharacters.indexOf(String.fromCharCode(k))!=-1); } else { return true; } } else { return true; } } </script> </head> <body bgcolor="#343331"> <!-- Header --> <div id="header"> <div id="headerleft"></div> <div id="headermiddle"><a href="index.php"><img src="img/logo.png"></a></div> <div id="headerright"> <?php echo "<form name='login' action='inc/$loginstatus.php' method='POST'>";?> <div class="loginboxdiv" id="username"> <input type="text" class="loginbox" name="username" value="Username" onFocus="make_blank();" onBlur="undoBlank();"> </div> <div class="loginboxdiv" id="password"> <input class="loginbox" type="text" name="password" type="text" value="Password" onFocus="make_blank1();" onBlur="undoBlankpass();"> </div> <div id="login"> <?php echo "<input type='image' src='img/$loginstatus.png' alt='".ucfirst($loginstatus)."'>";?> </div> </form> <div id="register"> <a href="register.php"><img src="img/register.png"></a> </div> <div id="forgotpassword"> <a href="resetpassword.php" class="forgot">Forgot Password?</a> </div> </div> </div> <!-- Content Top --> <div id="contenttop"> <div id="links"> <table cols="7"> <tr> <td align="center" valign="middle" width="100px" height="48px"><a href="index.php"><img src="img/home.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="member.php"><img src="img/member.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="addsheet.php"><img src="img/addsheet.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="advertise.php"><img src="img/advertise1.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="faq.php"><img src="img/faq.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="terms.php"><img src="img/terms.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="contact.php"><img src="img/contact.png"></a></td> </tr> </table> <!-- 92x30 --> </div> </div> <!-- Content Middle --> <div id="contentmiddle"> <div id="content"> <div id="headeditsites"></div> <br /> <div id="editsite"> <form action="editsites.php" method="post" name="newsite"> Title: <input type="text" name="title" value="<?php echo $titledb; ?>"><br /> Url: <input type="text" name="url" value="<?php echo $urldb; ?>"><br /> Max Views: <input type="text" maxlength="11" id="NumbersOnly" onkeypress="return inputLimiter(event,'NumbersOnly')" name="maxviews" value="<?php echo $maxviewsdb; ?>"><br /> <select name="status"><option value='Active' name='active'>Active</option><option value='Passive' name='passive'>Passive</option></select><br /><br /> <center><input type="submit" name="editnewsite" value="Edit Site"></center> </form> </div> </div> </div> <!-- Content Bottom --> <div id="contentbottom"> </div> </body> </html> Hi All, first of all. Sorry for signing up to the site and then immediately asking for help. I hate doing it but always seems to be the way people get involved with forums these days and it seems I am no different... So thank you in advance if you are kind enough to answer! Among many personal flaws, my issue is a technical one regarding the ability to retain session variables. Unfortunately whilst the website itself is not complicated, the problem is not as simple as just running session_start(); and letting it get on and do its own thing. So the problem exists around a relatively simple contact form and the basic Turing test that it uses to prove the user is human. The script adds a value to the $_SESSION variable and then on the next page load, tests to see if the variable is still there. As per this little function: function cookiesEnabled() { if ($_SESSION['cookiesEnabledTest']) $_SESSION['cookiesEnabled'] = true; else $_SESSION['cookiesEnabledTest'] = true; } Now for what must be 95% of all users, the variable is still there, proving the the session is being maintained as the user navigates the site. Unfortunately a small group of computers appear to be having difficulties with this for a not too clear reason. The computers have varying browser user agents indicating that they are all (so far) using one of the following: MSIE 8 MSIE 7 MSIE 7 in what appears to be MSIE 6 compatibility mode Now in testing, I can't get MSIE 8 or MSIE 7 to produce the same effect, with exception to MSIE 8 in "InPrivate" browsing mode. In this mode it is easy to see that there is no cookie txt file being created and thus no way of the browser to pass back the session id on the next page load. I can't think of any detail that I have missed out, but if there is anything I have left unclear, please let me know! Thanks again! Felix I have this code to update mysql db. It deletes and updates everything in the row except for the date. The date remains the same. In my db i have it under "prices" and it is named "date". Here is the code I am using. Code: [Select] if($user_id !="" && $name !="" && $update=="yes"){ mysql_query("DELETE FROM prices WHERE id='".$_POST['id']."'"); $resultado = "You successfully updated this posting!<br>Thank you for participating."; $date=getdate(); $insert=mysql_query("INSERT INTO prices VALUES ('', '$user_id', '$name', '$bus_type', '$street', '$city', '$state', '$zip_code', '$brand', '$quantity', '$price1', '$price2', now())"); } Hi I have deleted quite lot data from mysql database however, php still shows that page but blank ie page.php?id=186 - this id and all assosiated fields with this id has been removed from mysql but id still showing on the net and google cached all of them ( 600 pages) . page.php is still in use but I was wondering if there is any way not to show these blank pages/ids from mysql db and more importantly how can I remove these blank pages from google? Thanks for your help. How can I recover deleted iphone contacts?
I have a mysql table like so ID OrderID Name Image CatalogID 1 1 test pic1.jpg 1 2 2 test2 pic2.jpg 1 3 1 test3 pic3.jpg 2 4 1 test4 pic4.jpg 3 5 1 test5 pic5.jpg 4 6 2 test6 pic6.jpg 4 7 3 test7 pic7.jpg 4 etc etc (1) I want to use up and down buttons so that the OrderID can be modified to reflect the users order preference, how would I code it so it changes all the OrderID values in the table as necessary to produce the correct order using the buttons, the only affected items each time would be the ones in the same CatalogID group. (2) How do I re number the OrderID when an item is deleted so that it moves all the items below it in the same CatalogID group up one value to still reflect the correct order and not skip OrderID values. I have approximately 2,300 videos embedded on my site, and I am constantly adding more. The videos are hosted by YouTube. When a video is deleted from YouTube, it becomes unavailable on my site. Each video's ID is in my MySQL database. A video ID looks like this: ZFOuxAx-dkc I need a script that will do the following: select the IDs from my database check if the videos are still available on YouTube create a list of the videos that are unavailable. If possible, it would be great if the script could also tell me if any of the videos have been blocked in certain countries. The script has to be fully commented so that I can understand it. I want to run the script manually every few days. I don't want to have to change my database tables. I've been told that you can use YouTube's API or YouTube's oEmbed interface. I've also been told that, because there are so many videos, you will have to use cURL multi handles. If interested in this project, please PM me your price. This is an urgent project. I have placed ads elsewhere. Using MySQL and PHP. I have two tables mobiles and brands. mobiles has { mobileID |brandID | price| BrandName| MobileName} brands has { brandID | BrandName } In admin panel admin is able to delete both the table indivdiually but I want that if brand is deleted all the related mobiles should also be deleted How is this possible? I am trying to create an index page which contains registration and login field the problem that i get is on successful login a warning is displayed session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\Eventz.com\index.php:116) in C:\xampp\htdocs\Eventz.com\index.php on line 235 This is the login part of my index.php this tag is inside an html table below the login form I also have a registration form and its php code above the login form Code: [Select] <?php if (isset($_REQUEST['pass'])) { $id=$_POST['id']; $pass=$_POST['pass']; $conn =mysql_connect("localhost","root",""); if (!$conn) { die('Could not connect: ' . mysql_error()); } /* checking connection....success! */ $e=mysql_select_db('test', $conn); if(!$e) { die(''.mysql_error()); } else { echo 'database selected successfully'; } if (isset($_REQUEST['id']) || (isset($_REQUEST['pass']))) { if($_REQUEST['id'] == "" || $_REQUEST['pass']=="") { echo "login fields cannot be empty"; } else { $sql=mysql_query("Select email,password from login where email='$id' AND password='$pass'"); $count=mysql_num_rows($sql); if($count==1) /* $count checks if username and password are in same row */ { session_start(); $_SESSION['id']=$id; echo "</br>Login Successful</br>"; } else { echo "</br>invalid</br>"; echo "please try to login again</br>"; } } } } ?> Any help or suggestion would be appreciated I am having trouble resolving an error. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/s519970/public_html/header.php:27) in /home/s519970/public_html/admin/login.php on line 2 What I can gather is I can't use "header (Location: 'admin.php')" after i've used session_start(). I have tried to replace the header (Location: 'admin.php') with this: echo "<script>document.location.href='admin.php'</script>"; echo "<script>'Content-type: application/octet-stream'</script>"; I've been trying to read up on solutions but haven't been able to get it sorted. If anyone can offer some advice that would be greatly appreciated as im new to php. Code: [Select] <?php session_start(); if(isset($_SESSION['user'])) echo "<script>document.location.href='admin.php'</script>"; echo "<script>'Content-type: application/octet-stream'</script>"; ?> <div id="loginform"> <form action="dologin.php" method="post"> <table> <tr> <td><span>Username:</span></td> <td><input type="text" name="username" /></td> </tr> <tr> <td><span>Password:</span></td> <td><input type="password" name="password" /></td> </tr> <tr> <td colspan="2" align="right"><input type="submit" name="login" value="Login" /></td> </tr> </table> </form> </div> I have tried using require_once('yourpage.php'); before my <head></head> tags in the header document where I've specified the html information but this doesn't seem to work. I've been advised to use ob_start("ob_gzhandler"); but I am not sure how to implement this. Any advice is greatly appreciated! in this page http://maximaart.com/newscp/ i have this problem Code: [Select] Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/maximasy/public_html/newscp/index.php:1) in /home/maximasy/public_html/newscp/index.php on line 2 my source code is <?php session_start(); include_once("config.php"); include_once("functions.php"); $errorMessage = ''; if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) { if ($_POST['txtUserId'] === "$user" && $_POST['txtPassword'] === "$pass") { // the user id and password match, $_SESSION['basic_is_logged_in'] = true; require("main.php"); exit;?> I'm making a simple login system with MySQL and PHP (very simple, I'm just starting with PHP). The MySQL portion is done, but I need to ensure only people who are logged in can see certain content. To check if people are logged in, my website checks that they have the $_SESSION['user'] variable set. If it is set, then it lets them continue through the website, if not, it tells them to login. Is that enough security, or can people simply inject a session cookie into their browser to spoof that they are logged in? My idea was to generate a session key cookie when they login (just a random string of letters and numbers) and store that in the database, then on every page, check to make sure their session key is the same thing that's in the database. Is this necessary? It seems expensive. hi everyone. i'm wondering what the best way is to create a session variable and pass it to an iframe. i need to do something along these lines, but it doesn't seem to pass the ID. Any hints on how i should accomplish this? Code: [Select] session_start(); $_SESSION['ID']=$_GET['ID']; // id from previous page $ID=session_id(); <iframe src="iframepage.php?ID=<?php echo $ID; ?>" style="width:680px; height:200px;" noresize="noresize" frameborder="0" border="0" scrolling="Yes" allowtransparency="true" /> </iframe> Just curious how other people feel about this. I am working on an application where a lot of info is pulled from MySQL and needed on multiple pages.
Would it make more sense to...
1. Pull all data ONCE and store it in SESSION variables to use on other pages
2. Pull the data from the database on each new page that needs it
I assume the preferred method is #1, but maybe there is some downside to using SESSION variables "too much"?
Side question that's kind of related: As far as URLs, is it preferable to have data stored in them (i.e. domain.com/somepage.php?somedata=something&otherdata=thisdata) or use SESSION variables to store that data so the URLs can stay general/clean (i.e. domain.com/somepage.php)?
Both are probably loaded questions but any possible insight would be appreciated.
Thanks!
Greg
Edited by galvin, 04 November 2014 - 10:30 AM. |