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 11 of 11
  1. #1
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts

    $_SESSION returning different results on windows and linux

    I've encountered a little problem and I'm not sure why basically.

    The site I'm working on has 3 login area's .

    In the case of each login area I store a userID and various other information in a session.

    On Member Login I store this:

    PHP Code:
    $_SESSION['userid'] = $userdetails[0].",".$_POST['myusername']; 
    On Company Login I store this:

    PHP Code:
    $_SESSION['corpid'] = $actual_id[0]; 
    And on Admin Login I store this

    PHP Code:
    $_SESSION['adminid'] = $userdetails[0].",".$userdetails[3].",".$userdetails[4]; 
    Now here's where the fun begins.

    On the userid the front end works perfectly on both the linux server and the windows dev machine when i do $_SESSION['userid'][0] or $_SESSION['userid'][1]

    The corpid session always works fine since its only a single int stored.

    The admin session is where the fun begins.
    On windows doing a print_r of the session returns this

    1,Administrator,emailaddress

    perfect just what I want. on the linux server a print_r returns this though
    Array ( [0] => Array )

    So me thinking that perhaps I just need to explode out the string stored.

    PHP Code:
    $adminid=explode(",",$_SESSION['adminid']); 
    Now print_r ($adminid); on windows returns this
    Array ( [0] => 1 [1] => Administrator [2] => emailaddress )
    again perfect just what I want but on linux it returns this
    Array ( [0] => Array )

    Am I being massively stupid with array handling here or am I missing something completely?

    I'm a little confused since it works on the user front end fine and only appears to cause a problem in the admin area with the adminid session.
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    i have tested this one both a window and 2 different linux servers and i get the same response on all of them...

    Array ( [0] => 1 [1] => admin [2] => email )

    the code i used was just copied from ur examples
    Code:
    $_SESSION['adminid'] = "1,admin,email";  
    
    $adminid=explode(",",$_SESSION['adminid']);
    
    print_r($adminid);

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Looks like the real problem is your $_SESSION['adminid'] is getting unset somewhere, for reasons unknown to me.

  • #4
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    Quote Originally Posted by mic2100 View Post
    i have tested this one both a window and 2 different linux servers and i get the same response on all of them...

    Array ( [0] => 1 [1] => admin [2] => email )

    the code i used was just copied from ur examples
    Code:
    $_SESSION['adminid'] = "1,admin,email";  
    
    $adminid=explode(",",$_SESSION['adminid']);
    
    print_r($adminid);
    I know confused the hell out of me too. especially since it works in all other area's just the admin area it fails in

    Quote Originally Posted by Fumigator View Post
    Looks like the real problem is your $_SESSION['adminid'] is getting unset somewhere, for reasons unknown to me.
    This could be a possiblity too but I can't for the life of me work out where/if and surely if it was being unset doing print_r on it wouldn't even return the word "array" if it was unset would it ?
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com

  • #5
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Well, yeah, not unset-- just an empty array is being assigned to it. Throw a bunch of print_r's in everywhere to see what happens to it...? I mean does it ever have the right value? This is what I like to call brute force troubleshooting, just spam enough output until the culprit is revealed.

  • #6
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    done that on the windows dev server and its fine the session adminid contains the correct information all the way through until the end of the footer

    on the linux server though if i print_r it even just after its been set it contains just "Array"

    I still don't understand why the userid session which is created in exactly the same way works fine on both the windows and the linux server.
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com

  • #7
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    So it's not really $_SESSION['adminid'], it's $userdetails[0].",".$userdetails[3].",".$userdetails[4];

    Where's that stuff coming from? Does it look OK from inception?

  • #8
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    yeah its all pulling the correct details out and its populating it correctly. if I echo out the string before setting it into the session its correct.

    Just as soon as I dump it into a session it fails but again its only on the linux server its failing on the windows server its working perfectly.
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com

  • #9
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    any one else got any suggestions of things I can try?
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com

  • #10
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    I know confused the hell out of me too. especially since it works in all other area's just the admin area it fails in
    Have you made any error in choosing the right operator(say a = instead of ==) somewhere in the program? Could you post the complete code in that file?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #11
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    Quote Originally Posted by abduraooft View Post
    Have you made any error in choosing the right operator(say a = instead of ==) somewhere in the program? Could you post the complete code in that file?
    can't really post the entire code no since its in excess of 5k lines

    Basicaly though I create the session as above thats a copy and paste code.

    Then when I want to retrieve anything out of it usually I just do
    PHP Code:
    <?php echo $_SESSION['adminid'][0];?>
    <?php 
    echo $_SESSION['adminid'][1];?>
    <?php 
    echo $_SESSION['adminid'][2];?>
    etc when I noticed that didn't work on the linux machine thats when I then tried splitting it down into an array $adminid via explode again exact code pasted above.

    As far as i'm aware though there's no operand difference between = and == in linux and windows versions of php so if it works on windows it should work on linux all I can think is that there's a session handling issue.

    The main site is under domain/ the admin panel is under domain/admin/ though do sessions have session domains perhaps ?
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com


  •  

    Posting Permissions

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