www.webdeveloper.com
Results 1 to 4 of 4

Thread: Superseded PHP Session Side-Effect existed until 4.2.3

Hybrid View

  1. #1
    Join Date
    Nov 2013
    Posts
    10

    Superseded PHP Session Side-Effect existed until 4.2.3

    Hello,

    I have tried changing all my login scripts from the old session_registered and $username=$_SESSION['Username'] but for some reason the new method of code doesn't work either and now thing will work, please help as i am lost

    Check LOGIN Page
    PHP Code:
    <? 
    session_start
    ();
    session_destroy();
    ?>
    <?php

    // username and password sent from signup form 
    $Username=$_POST['PostUsername']; 
    $Password=$_POST['PostPassword'];

    $sql="SELECT * FROM $tbl_name WHERE username='$Username' and password='$Password'";
    $result=mysql_query($sql);
    $count=mysql_num_rows($result);

    if(
    $count==1){

    // Register $Username, $Password and redirect to file "logged_h.php"
    $_SESSION['Username'] = $Username;
    $_SESSION['Password'] = $Password;
    header("location:logged_in.php");
    }
    else {
    session_destroy();
    header("location:login_failure.php");
    }
    ?>
    Here is my Logged in code to check to see if the user is registered.
    PHP Code:
    <?php
    session_start
    ();

    if(isset(
    $_SESSION['Username'])){

    $sql="SELECT * FROM $tbl_name WHERE username='$Username' and password='$Password' LIMIT 1";
    $result=mysql_query($sql) or die("SQL Error: $sql<br>" mysql_error()); 
    $rows=mysql_fetch_array($result);
    $usernamematch=$rows['username'];
    if(
    $usernamematch==$Username){
    $logincheck="pass";
    }
    else{
    $checkuser="failed";
    session_start();
    session_destroy();
    }
    }
    else{
    $checkuser="failed";
    session_start();
    session_destroy();
    }
    ?>

  2. #2
    Join Date
    Nov 2013
    Posts
    10
    Forgot to mention:
    phpMyAdmin = Ver 4.0.8
    Database Version = 5.1.65
    Web Server = libmysql - 5.0.96

  3. #3
    Join Date
    Nov 2013
    Posts
    10
    This is the reason for me updating my scripts (Well trying too):

    PHP Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled.

  4. #4
    Join Date
    Sep 2013
    Posts
    221
    There is a session variable given the same name as some existing global variable (i.e. both $_SESSION['username'] and $username exists).
    Rename either of them.

    or basically you have a variable with the same name as your session. ex:

    $_SESSION['var1'] = null;
    $var1 = 'something';
    which will reproduce this error. you can stop PHP from trying to find existing variables and warning you about them by adding these lines to your script:

    ini_set('session.bug_compat_warn', 0);
    ini_set('session.bug_compat_42', 0);
    these values can be set in php.ini or .htaccess as well

    Hope this helps.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles