/    Sign up×
Community /Pin to ProfileBookmark

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

[code=php]<?
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”);
}
?>[/code]

Here is my Logged in code to check to see if the user is registered.

[code=php]<?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();
}
?>[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@falkyauthorNov 24.2013 — Forgot to mention:

phpMyAdmin = Ver 4.0.8

Database Version = 5.1.65

Web Server = libmysql - 5.0.96
Copy linkTweet thisAlerts:
@falkyauthorNov 24.2013 — 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.
Copy linkTweet thisAlerts:
@priyankagoundNov 26.2013 — 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.
×

Success!

Help @falky spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...