Jump to content


Photo

[SOLVED] session problem


  • Please log in to reply
5 replies to this topic

#1 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 28 April 2006 - 10:13 AM

i'm clueless this was working just fine.. and sudddunly it stopped working i never even touche dit after i made it work..

every user function stopped working..this a quick exaplem so someone can tell me if i did something wrong..

<?php
session_start();  ?>

<? if(isset($_SESSION['username'])){ echo "
        <table align='left' id='useroptions'>
          <tr>
            <td background='images/BOTTLOM.jpg'><p>
            ".$_SESSION['username'] . " </p>            </td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td background='images/BOTTLOM.jpg'><a href='phpscript/logout.php'><font color='#000000'>LogOut</font></a></td>
          </tr>
        </table>"; }?>
and the user check side looks a litle like this
<?php
session_start();  // Start Session
session_register("username");
include '../config/db.php';
// Conver to simple variables
$username = $_POST['username'];
$password = $_POST['password'];
if($login_check > 0){
    while($row = mysql_fetch_array($sql)){
    foreach( $row AS $key => $val ){
        $$key = stripslashes( $val );
    }
        // Register some session variables!
        session_register('username');
        $_SESSION['username'] = $username;
        session_register('password');
        $_SESSION['password'] = $password;
        
        mysql_query("UPDATE users SET last_login=now() WHERE username='$username'");
        
        header("Location: ../index.php");
    }
}

i know the rule say to chekc out the firs tpost if any one has any session problems.. but is that i wont find any problme with my scrip because it was working fine for few days..i don't know why stopped working and i keep chekcing it and it don't work when the user tries to log in..

also in the data base shows the user is online and evn tell if they viewing a page but on the page all the users tools are not display

#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 28 April 2006 - 12:29 PM

Not to use session_register() and $_SESSION. Just use $_SESSION. Read first caution box at:
[a href=\"http://us2.php.net/manual/en/function.session-register.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.session-register.php[/a]

FYI: Take a look at our session troubleshooting guide:
[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=31047&view=findpost&p=157705\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...ndpost&p=157705[/a]



#3 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 28 April 2006 - 02:45 PM

i trying with that simple code to test it..
<?PHP
session_start();
$_SESSION['test'] = 'Hello World!';
header('Location: read.php?' . SID);
exit;
?>
<?PHP
session_start();
echo isSet($_SESSION['test']) ? $_SESSION['test'] : 'Not Set';
?>

and is coming out as not set, but i done everything i let my computer accept any kind of cokies.. you think might be the server? becuse yaho is a big company they shouldn't be having those kind of problem i think..
and for something as usefull as session i know they must have it aneble.. i was just using it yesterday it just out of no where stopped working.. i tryed al possible way and it doesn't work :.(..

#4 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 28 April 2006 - 02:59 PM

oh forget it thank you for your help. i delete my tmp folder an di didn't even notice :|..NOOBS! :D

#5 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 28 April 2006 - 10:20 PM

toplay: So you're saying not use use both session_register('blah') and $_SESSION['blah']?

If I read the first caution right, it means that $_SESSION[] registers the session for me? So I'm just duplicating my code?


#6 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 29 April 2006 - 03:22 AM

[!--quoteo(post=369732:date=Apr 28 2006, 03:20 PM:name=SharkBait)--][div class=\'quotetop\']QUOTE(SharkBait @ Apr 28 2006, 03:20 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
toplay: So you're saying not use use both session_register('blah') and $_SESSION['blah']?
[/quote]
Yes.

[!--quoteo(post=369732:date=Apr 28 2006, 03:20 PM:name=SharkBait)--][div class=\'quotetop\']QUOTE(SharkBait @ Apr 28 2006, 03:20 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
If I read the first caution right, it means that $_SESSION[] registers the session for me?
[/quote]
Yes.

[!--quoteo(post=369732:date=Apr 28 2006, 03:20 PM:name=SharkBait)--][div class=\'quotetop\']QUOTE(SharkBait @ Apr 28 2006, 03:20 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
So I'm just duplicating my code?
[/quote]
Yes, and possibly making it worse because you would be having register_globals on (a security risk) for session_register() to work properly. Plus taking up more memory for the extra variables and the values they hold.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users