Jump to content

[SOLVED] session problem


corillo181

Recommended Posts

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..

[code]
<?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>"; }?>[/code]
and the user check side looks a litle like this
[code]<?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");
    }
}[/code]

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
Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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

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 :.(..
Link to comment
Share on other sites

[!--quoteo(post=369732:date=Apr 28 2006, 03:20 PM:name=SharkBait)--][div class=\'quotetop\']QUOTE(SharkBait @ Apr 28 2006, 03:20 PM) [snapback]369732[/snapback][/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) [snapback]369732[/snapback][/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) [snapback]369732[/snapback][/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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.