Losin session on added page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Infinity
Forum Commoner
Posts: 44
Joined: Mon Feb 02, 2004 12:48 pm

Losin session on added page

Post by Infinity »

win xp pro
apache
phpbb2 plus 1.3

I have a website which is linked through ezportal
when i log on everything is fine i can access all the ezportal links i.e. staff site, memberslist etc. when i click the link to the index page of my web site everything still seems fine however when i link to the next page in my site im logged out so somewhere i'm losing my session i have included

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
?>
at the top of each page

any ideas i'll put the code for my site pages below
the link from ezportal goes to this page

Code: Select all

<?php 
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'fetchposts.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
$page_title = "inf_index.php";

if ($userdata['session_logged_in'])   
{
//echo "Welcome ";
//echo $userdata[username];
//echo " you r logged in.";


include("inf_music_header.tpl");
include("inf_music_navbar.tpl"); 




echo "<table width='100%'  border='1' cellpadding='2' cellspacing='2' bordercolor='#006699' align='center'>"; 
echo "<tr>";
echo "<td width='100%' background='./templates/fisubsilversh/images/cellpic3.gif'><div align='center' class='style2 style3'><strong>
          UK Number 1 Singles</strong></div></td>";
echo "</tr>";
echo "</table>";
echo "<table width='100%'  border='1' cellpadding='2' cellspacing='2' bordercolor='#006699' align='center'>"; 


// set up field bar

echo "<td width='100%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>display some text to tell users about this part of the site and maybe add some flash animation and music
hggjhghjgjgjgjgjjgbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb</div></td>";



// Finally we close off the table 
echo "</table>"; 


include("inf_music_footer.tpl"); 

}
 else              
{          

echo "You r not logged in"; 
} 
?>
the link from the above page which is in a custom header goes to this page

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'fetchposts.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
$page_title = "inf_1_singles.php"; 

if ($userdata['session_logged_in'])    
{ 
//echo "Welcome ";
//echo $userdata[username];
//echo " you r logged in.";

include("inf_music_header.tpl"); 
$navbar = (int)$_GET['navbar']; 
if(!isset($_GET['navbar'])) 
{ 
//$navbar = 5; 
} 
if ($navbar == 5) 
{  
include("inf_music_navbar_1950s.tpl"); 
} 
elseif ($navbar == 6) 
{  
include("inf_music_navbar_1960s.tpl"); 
} 
elseif ($navbar == 7) 
{  
include("inf_music_navbar_1970s.tpl"); 
}  


 

   $location = "localhost"; 
   $username = "xxxx"; 
   $password = "xxxx"; 
   $database = "MYMUSIC"; 
   $conn = mysql_connect("$location","$username","$password"); 
$year = (int)$_GET['year']; 
if(!isset($_GET['year'])) 


  
   if (!$conn) die ("Could not connect MySQL"); 
   mysql_select_db($database,$conn) or die ("Could not open database"); 

$query = "SELECT * FROM numberones  WHERE `year` = '$year'"; 
   $result = mysql_query($query); 
   $numrows = mysql_num_rows($result); 




echo "<table width='100%'  border='1' cellpadding='2' cellspacing='2' bordercolor='#006699' align='center'>"; 
echo "<tr>"; 
echo "<td width='100%' background='./templates/fisubsilversh/images/cellpic3.gif'><div align='center' class='style2 style3'><strong> 
          Number 1 Singles from $year </strong></div></td>"; 
echo "</tr>"; 
echo "</table>"; 
echo "<table width='100%'  border='1' cellpadding='2' cellspacing='2' bordercolor='#006699' align='center'>"; 




echo "<td width='13%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Date</div></td>"; 
echo "<td width='33%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Artist</div></td>"; 
echo "<td width='39%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Title</div></td>"; 
echo "<td width='6%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Wks</div></td>"; 
echo "<td width='9%' background='./templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Download</div></td>";    

    
   while($row = mysql_fetch_array($result)) 



{ 
      echo "<tr><td background='./templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[year]</div></td></tc>"; 
      echo "<tc><td background='./templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[artist]</div></td></tc>"; 
      echo "<tc><td background='./templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[title]</div></td></tc>"; 
      echo "<tc><td background='./templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[weeksatone]</div></td></tc>"; 
	  echo "<tc><td background='./templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'><a href="$row[dllink]"><img src='./templates/fisubsilversh/images/icon_download.gif'></a></div></td></tr>"; 
} 



echo "</table>"; 

 
include("inf_music_footer.tpl"); 
// Release the Result Set
mysql_free_result($result);
// Close the connection
mysql_close($conn);

} 
else              
{          
echo "You r not logged in"; 
} 
?>
and its this last page i seem to be losing the session
whats going on
all my pages are in the phpbb2 root
Infinity
Forum Commoner
Posts: 44
Joined: Mon Feb 02, 2004 12:48 pm

Post by Infinity »

bump
tsg
Forum Contributor
Posts: 142
Joined: Sun Jan 12, 2003 9:22 pm
Location: SE, Alabama
Contact:

Post by tsg »

I admit, I didn't read the whole code and not real sure what you are doing with it, but I can tell you a couple of things that will cause you to loose a session and to check:

1) be sure that you have at the top of every page: session_start(); (I am sure you probably do)

2) be sure you are not going from http://www.domain.com/page.php -> domain.com/page.php (see the lose of the www).

I had a log in script that was driving me batty once that it was doing that.

Those are my 2 cents ...
Post Reply