Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Session problem

  1. #1
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts

    Session problem

    ive been having a bit of trouble with a new project im working on, it now keeps you logged in as before it didnt however once you logged in before you could see what was on the page now it just keeps you logged in but you cant see anything, i will show you the old scripts and the new.

    NEW

    Login Check:
    PHP Code:
    <?php
     
    if (isset($_SESSION['uID'])) {
      
    $query=mysql_query("SELECT * FROM users WHERE id=".$_SESSION['uID']);
      
    $user=mysql_fetch_object($query);

    function 
    logincheck(){
    if (empty(
    $_SESSION['uID'])){
      
    header('Location: index.php');
      exit;
    }}
    ?>
    Updates:

    PHP Code:
    <?php
    include('includes/db_connect.php');
    include(
    'includes/inc-logincheck.php');
    include(
    'includes/inc-functions.php');
    //include('includes/smile.php');
    $strTitle='Welcome';
    $strMessage='';

    $intUserID=$_SESSION['uID'];
    $fetch=$user;
    include(
    'includes/inc-head.php');
    ?>

    OLD

    Login Check:

    PHP Code:
    <?php
    if (isset($_SESSION['uID'])) {
      
    $query=mysql_query("SELECT * FROM users WHERE id=".$_SESSION['uID']);
      
    $user=mysql_fetch_object($query);
    } else {
      
    header('Location: index.php');
      exit;
    }
    ?>
    now I know its something to do with the login check. can anyone please help

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,851
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    ow it just keeps you logged in but you cant see anything, i will show you the old scripts and the new.
    I think you missed the important part, a call to function session_start() at the top of all pages.

    Edit: .. and where's the call to logincheck() ?
    Last edited by abduraooft; 12-19-2010 at 02:57 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    well this is the error that comes up with putting session_start() in the first line of every page

    Code:
    Parse error: syntax error, unexpected T_INCLUDE in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/adminupdates.php on line 3
    i fixed that, however the same problem exist with not being able to see what is on the page except for the background colour
    Last edited by Dan13071992; 12-19-2010 at 03:15 PM. Reason: i fixed the unexpected T_INCLUDE

  • #4
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    PHP Code:
    <?php
    include "config.php";
    session_start(); 
    include_once 
    "db_connect.php";
    $username=$_SESSION['username'];
    function 
    logincheck(){
    if (empty(
    $_SESSION['username'])){
    echo 
    "
    <SCRIPT LANGUAGE='JavaScript'>
    window.location='index.php';
    </script>
    "
    ;

    exit();

    }}
    that was how the old logincheck worked when it was in my functions.php now i have a new functions that isnt included yet and has nothing to do with the login.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •