title: PHP Session working on Desktop not on Mobile
body: <p>I'm trying to create a mobile site and I'm using sessions to get the users username.  When I view the mobile site on my desktop it works fine and I can get the username of the user from page to page.  But when I view the same site on my mobile browser the session doesn't carry over from page to page.</p>
  
  <p>Here is my login page:</p>
  
  <pre><code>&lt;?php
  //allow sessions to be passed so we can see if the user is logged in
  session_start();
  
  ob_start();
  
  //connect to the database so we can check, edit, or insert data to our users table
  $con = mysql_connect(***info to connect to database) or die(mysql_error());
  $db = mysql_select_db('dbname', $con) or die(mysql_error());
  
  //include out functions file giving us access to the protect() function made earlier
  include "./functions.php";
  
  $userid = $_SESSION['uid'];
  $lookupusername = mysql_query("SELECT * FROM users WHERE ID='$userid'");
  $row = mysql_fetch_assoc($lookupusername);
  $username = $row['username'];
  $usercountry = $row['country'];
  
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt; 
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt;
  &lt;title&gt;15:11 Project Mobile&lt;/title&gt;
  
  &lt;link rel="stylesheet" href="css/jquery.mobile-1.3.0.css" /&gt;
  &lt;link href="//netdna.bootstrapcdn.com/font-awesome/3.2.0/css/font-awesome.css" rel="stylesheet"&gt;
  &lt;script src="js/jquery-1.8.3.js"&gt;&lt;/script&gt;
  &lt;script src="js/jquery.mobile-1.3.0.js"&gt;&lt;/script&gt;
  &lt;/head&gt; 
  &lt;body&gt; 
  
  
  
  
  
  &lt;!-- BEGIN LOGIN PAGE --&gt;
  
  &lt;div data-role="page" id="login" style="background: #c66200;"&gt;
  
      &lt;div data-role="header"&gt;
      &lt;/div&gt;
      &lt;div data-role="content"&gt;
  
                  &lt;center&gt;
  
          &lt;div class="ui-grid-b"&gt;
                  &lt;img src="images/logo_white.png"&gt;
          &lt;/div&gt;
                  &lt;/center&gt;
  
          &lt;?
  
          //check if the login session does no exist
          if(strcmp($_SESSION['uid'],'') == 1){
              //if it doesn't display an error message
              header('Location: feed.php');
          }
  
  else {
  
  
          //If the user has submitted the form
          if($_POST['submit']){
              //protect the posted value then store them to variables
              $username = protect($_POST['username']);
                          $thepassword = md5($_POST['password']);
              $password = protect($thepassword);
  
              //Check if the username or password boxes were not filled in
              if(!$username || !$password){
                  //if not display an error message
                  echo "&lt;center&gt;You need to fill in a &lt;b&gt;Username&lt;/b&gt; and a &lt;b&gt;Password&lt;/b&gt;!&lt;/center&gt;";
              }else{
                  //if the were continue checking
  
                  //select all rows from the table where the username matches the one entered by the user
                  $res = mysql_query("SELECT * FROM `users` WHERE `username` = '".$username."'");
                  $num = mysql_num_rows($res);
  
                  //check if there was not a match
                  if($num == 0){
                      //if not display an error message
                      echo "&lt;center&gt;The &lt;b&gt;Username&lt;/b&gt; you supplied does not exist!&lt;/center&gt;";
                  }else{
                      //if there was a match continue checking
  
                      //select all rows where the username and password match the ones submitted by the user
                      $res = mysql_query("SELECT * FROM `users` WHERE `username` = '".$username."' AND `password` = '".$password."'");
                      $num = mysql_num_rows($res);
  
                      //check if there was not a match
                      if($num == 0){
                          //if not display error message
                          echo "&lt;center&gt;The &lt;b&gt;Password&lt;/b&gt; you supplied does not match the one for that username!&lt;/center&gt;";
                      }else{
                          //if there was continue checking
  
                          //split all fields fom the correct row into an associative array
                          $row = mysql_fetch_assoc($res);
  
                          //check to see if the user has not activated their account yet
                          if($row['active'] != 1){
                              //if not display error message
                              echo "&lt;center&gt;You have not yet &lt;b&gt;Activated&lt;/b&gt; your account!&lt;/center&gt;";
                          }else{
                              //if they have log them in
  
                              //set the login session storing there id - we use this to see if they are logged in or not
                              $_SESSION['uid'] = $row['id'];
                              //show message
                              echo "&lt;center&gt;You have successfully logged in!&lt;/center&gt;";
  
                              //update the online field to 50 seconds into the future
                              $time = date('U')+50;
                              mysql_query("UPDATE `users` SET `online` = '".$time."' WHERE `id` = '".$_SESSION['uid']."'");
  
                              //redirect them to the usersonline page
                              $loginpage="#feed";
                              header("Location: feed.php" . $loginpage);
                              exit();
                          }
                      }
                  }
              }
          }
  }
  
          ?&gt;
                  &lt;center&gt;
  
          &lt;form action="index.php#feed" method="post" data-ajax="false"&gt;
              &lt;div style="width: 75%; border-top: 1px solid #ffffff; margin-top: 20px; padding-top: 20px; border-bottom: 1px solid #ffffff; margin-bottom: 20px; padding-bottom: 20px;"&gt;
              &lt;div class="ui-hide-label"&gt;
                  &lt;label for="username"&gt;Username:&lt;/label&gt;
                  &lt;input type="text" name="username" id="username" value="" placeholder="username" data-mini="true" style="color: #c66200;"/&gt;&lt;br&gt;
                  &lt;label for="password"&gt;password:&lt;/label&gt;
                  &lt;input type="password" name="password" id="password" value="" placeholder="password" data-mini="true" style="color: #c66200;"/&gt;&lt;br&gt;
              &lt;/div&gt;
  
              &lt;div style="width: 40%;"&gt;
                  &lt;input type="submit" data-role="button" name="submit" value="Login" data-mini="true" style="color: #c66200 !important;"/&gt;
              &lt;/div&gt;
              &lt;/div&gt;
  
                  &lt;/center&gt;
  
          &lt;?
          ob_end_flush();
          ?&gt;
  
  
      &lt;/div&gt;
      &lt;div data-role="footer"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;!-- END LOGIN PAGE --&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is what I have for my feed.php page which the login page routes to.  I can get the users info on this page.  Whenever I click a link to go to the "browseresults" page the information doesn't carry over.</p>
  
  <pre><code>&lt;?php
  //allow sessions to be passed so we can see if the user is logged in
  session_start();
  
  ob_start();
  
  //connect to the database so we can check, edit, or insert data to our users table
  $con = mysql_connect(***db info***) or die(mysql_error());
  $db = mysql_select_db('dbname', $con) or die(mysql_error());
  
  //include out functions file giving us access to the protect() function made earlier
  include "./functions.php";
  
  $userid = $_SESSION['uid'];
  $lookupusername = mysql_query("SELECT * FROM users WHERE ID='$userid'");
  $row = mysql_fetch_assoc($lookupusername);
  $username = $row['username'];
  $usercountry = $row['country'];
  
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt; 
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt;
  &lt;title&gt;15:11 Project Mobile&lt;/title&gt;
  
  &lt;link rel="stylesheet" href="css/jquery.mobile-1.3.0.css" /&gt;
  &lt;link href="font-awesome/css/font-awesome.css" rel="stylesheet"&gt;
  &lt;script src="js/jquery-1.8.3.js"&gt;&lt;/script&gt;
  &lt;script src="js/jquery.mobile-1.3.0.js"&gt;&lt;/script&gt;
  &lt;/head&gt; 
  &lt;body&gt; 
  
  
  
  
  &lt;!-- BEGIN PAGE 3 --&gt;
  
  &lt;div data-role="page" id="browse"&gt;
      &lt;div data-role="panel" id="settingspanel" data-position="left" data-display="overlay"&gt;
          &lt;ul data-role="controlgroup"&gt;
              &lt;li&gt;&lt;a href="#submit" data-role="button"&gt;Page Two&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="#browse" data-role="button"&gt;Page Three&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="#projects" data-role="button"&gt;Page Four&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="log_out.php" data-role="button"&gt;Logout&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  
      &lt;div data-role="header" data-position="fixed" data-theme="c" data-tap-toggle="false" data-id="foo1" style="padding-top: 5px; border-bottom: 1px solid #eccfb3; padding-bottom: 5px;"&gt;
          &lt;a href="#settingspanel" data-role="button" data-iconpos="notext" class="icon-reorder icon-2x" style="background: none; margin-left: 20px;"&gt;&lt;/a&gt;
          &lt;center&gt;&lt;img src="images/logo_app_white.png" width="30px"&gt;&lt;/center&gt;
      &lt;/div&gt;
      &lt;div data-role="content"&gt;   
  
  
  
  
  
  &lt;?php
  $fquery = "SELECT state, city, count(city) as num FROM needs WHERE country='$usercountry' AND status='posted' GROUP BY state, city ORDER BY state, city";
  if ($result = mysql_query($fquery)) {
      $num_rows = mysql_num_rows($result);
  
      echo "&lt;table&gt;";
      $i = 1;
      $cols = 2;
  $prev = "";
  
      while ($frows = mysql_fetch_array($result)) {
          $fcity = $frows['city'];
          $fstate = $frows['state'];
          $fcitycount = $frows['num'];  // num is holding your count by city
  
  if ($fstate != $prev) {
  echo "&lt;tr&gt;&lt;/tr&gt;&lt;tr&gt;&lt;/tr&gt;&lt;tr&gt;&lt;/tr&gt;&lt;tr&gt;&lt;/tr&gt;&lt;tr&gt;&lt;/tr&gt;&lt;tr&gt;&lt;/tr&gt;&lt;tr&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th align='left'&gt;$fstate&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;";
  }
  
          echo "&lt;td&gt;&lt;a href='browseresults.php?city=$fcity&amp;state=$fstate'&gt;$fcity, $fstate ($fcitycount)&lt;/a&gt; &lt;/td&gt;";
  echo ($i &lt; $num_rows) ? ((($i % $cols) == 0) ? '&lt;/tr&gt;' : '') : '';
          $i++;
  
  
  $prev = $fstate;
      }
      echo "&lt;/table&gt;";
  }
  
  ?&gt;
  
  
  
  
  
      &lt;/div&gt;
      &lt;div data-role="footer" data-position="fixed" data-theme="c" data-tap-toggle="false" data-id="foo1" style="border-top: 1px solid #eccfb3; padding-top: 5px;"&gt;
          &lt;div data-role="navbar" style="background: #ce8339;"&gt;
              &lt;ul&gt;
                  &lt;li&gt;&lt;a href="#feed" class="icon-tasks icon-2x"&gt;My Feed&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#submit"class="icon-upload icon-2x"&gt;Submit&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#browse" class="icon-search icon-2x"&gt;Browse&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#projects" class="icon-folder-open-alt icon-2x"&gt;Projects&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;&lt;!-- /navbar --&gt;  
      &lt;/div&gt;
  
  
  &lt;/div&gt;
  
  &lt;!-- END PAGE 3 --&gt;
  
  
  
  
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And here is the browseresults.php page which is the page that is not getting the session data.</p>
  
  <pre><code>&lt;?php
  //allow sessions to be passed so we can see if the user is logged in
  session_start();
  
  ob_start();
  
  //connect to the database so we can check, edit, or insert data to our users table
  $con = mysql_connect(***dbinfo***) or die(mysql_error());
  $db = mysql_select_db(dbname, $con) or die(mysql_error());
  
  //include out functions file giving us access to the protect() function made earlier
  include "./functions.php";
  
  $userid = $_SESSION['uid'];
  $lookupusername = mysql_query("SELECT * FROM users WHERE ID='$userid'");
  $row = mysql_fetch_assoc($lookupusername);
  $username = $row['username'];
  $usercountry = $row['country'];
  
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt; 
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt;
  &lt;title&gt;15:11 Project Mobile&lt;/title&gt;
  
  &lt;link rel="stylesheet" href="css/jquery.mobile-1.3.0.css" /&gt;
  &lt;link href="font-awesome/css/font-awesome.css" rel="stylesheet"&gt;
  &lt;script src="js/jquery-1.8.3.js"&gt;&lt;/script&gt;
  &lt;script src="js/jquery.mobile-1.3.0.js"&gt;&lt;/script&gt;
  &lt;/head&gt; 
  &lt;body&gt; 
  
  
  &lt;!-- BEGIN PAGE 1 --&gt;
  
  &lt;?
  echo "$username";
  ?&gt;
  
  &lt;!-- END PAGE 1 --&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>no username is outputted.  Can anyone help explain why and help me get this sorted out please?</p>