...

View Full Version : newbie sessions problem



david mccarthy
02-21-2008, 06:02 PM
Just a quick one - I have secure login script that is working perfectly on my laptop (WAMP) using PHP5, and it will not function whatsoever on PC with same WAMP configuration. It seems to have a problem with sessions and is just showing garble on the screen. I have checked the obvious like accepting cookies and seems okay. The code is the exact same as on laptop... Would it be a problem with where and if the cookies are being writen to, or am I making no sense at all....? doh.

I am pretty newbie to this, but it seems like a fixable problem as I got it running on laptop.. All help much apprecaited..

greetings from Ireland!

CFMaBiSmAd
02-21-2008, 06:06 PM
For anyone in a Forum to be able to help, we need to see what you see. Post your code and post the garble that you are getting as output.

o0O0o.o0O0o
02-22-2008, 01:58 AM
it will not function whatsoever on PC with same WAMP configuration

Can u tell us what error you are getting or its just showing blank screen



greetings from Ireland!

I like greetings from Ireland :)

david mccarthy
02-22-2008, 12:18 PM
hi - thanks for the replies guys.

Basically, I have used the scripts from Login System v2.0 at http://www.evolt.org/PHP-Login-System-with-Admin-Features?from=50&comments_per_page=50

I have incorporated it in my own site all ok, but will not work in another PC with same config (WAMP). MySQL appears to be okay etc...

This is a copy of what I get when looking at main.php (this is a screen print)
You will have to excuse me a little guys as this is my frst posting.

thanks - dave :-)

------------------
logged_in){ echo "
Logged In
"; echo "Welcome $session->username, you are logged in.

" ."[username\">My Account] " ."[Edit Account] "; if($session->isAdmin()){ echo "[Admin Center] "; } echo "[Logout]"; } else{ ?>
Login
num_errors > 0){ echo "".$form->num_errors." error(s) found"; } ?>
Username: "> error("user"); ?>
Password: "> error("pass"); ?>
value("remember") != ""){ echo "checked"; } ?>> Remember me next time

[Forgot Password?]

Not registered? Sign-Up!


"; echo "Member Total: ".$database->getNumMembers()."
"; echo "There are $database->num_active_users registered members and "; echo "$database->num_active_guests guests viewing the site.

"; include("include/view_active.php"); ?>

rafiki
02-22-2008, 01:23 PM
logged_in){ echo "
Logged In
"; echo "Welcome $session->username, you are logged in.

" ."[username\">My Account] " ."[Edit Account] "; if($session->isAdmin()){ echo "[Admin Center] "; } echo "[Logout]"; } else{ ?>
Login
num_errors > 0){ echo "".$form->num_errors." error(s) found"; } ?>
Username: "> error("user"); ?>
Password: "> error("pass"); ?>
value("remember") != ""){ echo "checked"; } ?>> Remember me next time

[Forgot Password?]

Not registered? Sign-Up!


"; echo "Member Total: ".$database->getNumMembers()."
"; echo "There are $database->num_active_users registered members and "; echo "$database->num_active_guests guests viewing the site.

"; include("include/view_active.php"); ?>

sorry just for easier readability

rafiki
02-22-2008, 01:24 PM
your closing the PHP param tags ?>


logged_in){ echo "
Logged In
"; echo "Welcome $session->username, you are logged in.

" ."[username\">My Account] " ."[Edit Account] "; if($session->isAdmin()){ echo "[Admin Center] "; } echo "[Logout]"; } else{
num_errors > 0){ echo "".$form->num_errors." error(s) found"; }
Username: > error("user");
Password: > error("pass");
value("remember") != ""){ echo "checked"; }


echo "Member Total: ".$database->getNumMembers();
echo "There are $database->num_active_users registered members and ";
echo "$database->num_active_guests guests viewing the site.";
include("include/view_active.php"); ?>
some of this stuff doesnt make sense.

david mccarthy
02-22-2008, 01:27 PM
thanks for that rafiki -

the element you have made easier to read
was actually the screen output when browsing main.php - not the actual code...

Is there an easier way to dump this screenprint to show the errors I am getting? Sorry for the confusion.

Dave

rafiki
02-22-2008, 01:29 PM
you have a URL? then we can all see what the errors are.

david mccarthy
02-22-2008, 01:33 PM
its on a local host at the moment - i will put it online if you give me a few minutes there....

thanks for your help...

CFMaBiSmAd
02-22-2008, 01:54 PM
The code is using the lazy-way short open tags - <? (and probably <?=), which makes the code non-portable between servers with different settings. Even php.net recommends that short open tags are not used on code that might be publicly distributed -


; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.

You could turn on short open tags, but it would be much better to correct the code, because if you change hosts at some time in the future, you might get one where short open tags are off (they also cause a problem with <?xml tags) and you won't have the ability to turn them on.

So, change any <? to <?php and any <?= to <?php echo to fix the code so that it will work independent of the short tag setting.

Short open tags are such a huge problem that while php.net is not currently planning on eliminating them in php6, they are considering putting in a test that will generate an error when mixing <? and <?php within the same file, to enforce consistency (I suspect that the top dog at php.net won't allow them to be eliminated, sadly, but doing so would force people to write code that would always work and would eliminated posts like this in help forums where code works on one server and not another.)

david mccarthy
02-22-2008, 02:04 PM
Thanks for that - I was not aware of that and will correct the code.

I am not sure if this is the problem in this instance however, as the code is not hosted at the moment. The same code, apart from MySQL connection strings, is exactly the same - it is running perfect on my XP laptop on WAMP config, no problems. When I try the same on a XP desktop it is giving me problems with sessions - at least from what I can make out. Running the same code withou the login scripts runs just fine, and is using MySQL, but no sessions. I guess my question really is if there is something obvious that I am missing? Cookies are enabled and I can see that PHPSESSID has a cookie session. Could it be that the are not being written / saved properly?

Hope this makes sense...

Dave

david mccarthy
02-22-2008, 02:05 PM
sorry - i forgot to mention that i am using localhost on both machines...

CFMaBiSmAd
02-22-2008, 02:22 PM
Turning on full php error reporting and/or checking your web server log files for errors will tell you of any problems that php detects while running your code, such as problems with headers being sent, session save path settings...

Turning on full error reporting in php.ini (or a .htaccess file) is best because it will also cause fatal parse errors to be displayed. Change the following two lines in php.ini and stop and start your web server to get any changes made to php.ini to take effect -


error_reporting = E_ALL | E_STRICT
display_errors = On



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum