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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Problems calling a session

    The problem i have really confuses me.

    When i classify a session to the user (in either the login.php or register.php page) the page userarea.php displays properly.

    If i then refresh the page or click a link to userarea.php all the info disappears.

    I have tried echoing the session variable to see whats going on and instead of being "1" (the users id number) the variable changes to "Array" once refreshed.

    I never actually touched the variable and all three pages have session_start(); in them.

    Any ideas?
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  2. #2
    Senior Coder Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,651
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Find out what's in the session variable:
    PHP Code:
    var_dump($_SESSION); 
    It's being modified somewhere in the file(or one that it includes). Do a search for $_SESSION in your file(s).

  3. #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,801
    Thanks
    3
    Thanked 443 Times in 433 Posts
    It is likely that the session is not starting. Add the following two lines after the first opening <?php tag to get php to help you -

    PHP Code:
    ini_set ("display_errors""1");
    error_reporting(E_ALL); 
    Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

  4. #4
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Thanks for the error reporting code. I probably should just leave that in for good practice.

    I found the error too. I was calling a variable called $username and my session was called $_SESSION['username'] which for some reason made itself break.

    Is there a way of turning this off?

    Thanks.
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  5. #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,801
    Thanks
    3
    Thanked 443 Times in 433 Posts
    That's due to register globals being on. Turn them off or use unique names for all program/post/get/cookie/session variables.

    In addition to being a security risk by intentionally populating same name variables from external variables, register globals also causes unintentional overwriting of same name variables even if you don't want them to be.
    Last edited by CFMaBiSmAd; 03-10-2008 at 08:01 PM.
    Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.


 

Posting Permissions

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