Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-10-2008, 01:23 AM   PM User | #1
danielwarner
Regular Coder

 
Join Date: Oct 2005
Location: Surrey, England
Posts: 286
Thanks: 2
Thanked 2 Times in 2 Posts
danielwarner is an unknown quantity at this point
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.
danielwarner is offline   Reply With Quote
Old 03-10-2008, 01:28 AM   PM User | #2
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
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).
Inigoesdr is offline   Reply With Quote
Old 03-10-2008, 03:29 AM   PM User | #3
CFMaBiSmAd
Senior Coder

 
CFMaBiSmAd's Avatar
 
Join Date: Oct 2006
Location: Denver, Colorado USA
Posts: 2,711
Thanks: 2
Thanked 251 Times in 243 Posts
CFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the rough
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); 
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
CFMaBiSmAd is offline   Reply With Quote
Old 03-10-2008, 06:22 PM   PM User | #4
danielwarner
Regular Coder

 
Join Date: Oct 2005
Location: Surrey, England
Posts: 286
Thanks: 2
Thanked 2 Times in 2 Posts
danielwarner is an unknown quantity at this point
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.
danielwarner is offline   Reply With Quote
Old 03-10-2008, 06:57 PM   PM User | #5
CFMaBiSmAd
Senior Coder

 
CFMaBiSmAd's Avatar
 
Join Date: Oct 2006
Location: Denver, Colorado USA
Posts: 2,711
Thanks: 2
Thanked 251 Times in 243 Posts
CFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the rough
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.
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

Last edited by CFMaBiSmAd; 03-10-2008 at 07:01 PM..
CFMaBiSmAd is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:10 PM.


Advertisement
Log in to turn off these ads.