Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > PHP Programming
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-05-2009, 05:01 PM
  #1
jacek
Novice (Level 1)
 
Join Date: Apr 2009
Posts: 1
iTrader: (0)
jacek is an unknown quantity at this point
Session not working on live server

Hi,

It's about login script in PHP and MySQL.

While everything is cool on localhost (xamp), when the files are uploaded to live server (PHP 4.3.2) Session seems not to work. To make it even more confusing I've tested the script on two other web servers (PHP 4.4.9) and it worked fine.

A few snippets:

LOGIN.PHP

//Start session
session_start();
.............................
.............................
.............................

//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
session_write_close();
header("location: members.php");
exit();
}else {
//Login failed
header("location: login-failed.php");
exit();
}
----------------------------------------------------

MEMBERS.PHP


<?php
//Start session
session_start();

//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
header("location: access-denied.php");
exit();
}
?>

........more code..............
......................................

and of course access-denied.php loads in as $_SESSION['SESS_MEMBER_ID'] doesn't exist

I've also run little test on the server and it worked FINE:

SESSION.PHP

<?php
session_start();
$_SESSION['text'] = 'some text some text';
?>

<a href="session_after.php">test</a>

SESSION_AFTER.PHP
<?php
session_start();
echo $_SESSION['text'];
?>

RESULT --> printed "some text some text". All good

Last test I did was modification of the above and it didn't work:


<?php
session_start();
$_SESSION['text'] = 'some text some textn';
header("location: next_page.php");
?>


next_page.php
<?php
session_start();
echo $_SESSION['test'];
?>

RESULT ---> NOTHING!

I lost my head and don't know anymore what's going on. Thanks for any help

Jacek
jacek is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-22-2009, 08:40 AM
  #2
scoutt
Mister Admin to you
 
scoutt's Avatar
 
Join Date: Jul 2001
Posts: 30,730
iTrader: (0)
scoutt is a jewel in the roughscoutt is a jewel in the roughscoutt is a jewel in the rough
first, why are you using these?

session_regenerate_id();
session_write_close();

You don't need those. Is this server yours or a webhosts? What OS is it running on? seems like your headers are moving you to the next page faster than the server can generate the session file.
__________________
Have a Script or Snippet you want to share?

WWW Standards: HTML 4.01, CSS2.1, CSS3, XHTML 1.0
PHP Standards: PHP Standards
scoutt is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 10:38 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.