getting logged out when visiting custom page

Discussion forum for MOD Writers regarding MOD Development.
Locked
craiga
Registered User
Posts: 191
Joined: Fri Apr 10, 2009 8:14 am
Contact:

getting logged out when visiting custom page

Post by craiga » Thu Apr 01, 2010 9:50 pm

Whenever i visit my custom page, the custome page does not recognise that i am logged in. I can however pass in my sid and it recognises me then, but i would rather not have to do that.

Any idea why this might be the case?

my custom php page is at the same level as the main index.php and begins with

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'rankings.' . $phpEx); //custom php file

// Start session management
$user->session_begin();
$auth->acl($user->data);
 $user->setup();

Comkid
Registered User
Posts: 132
Joined: Thu Mar 25, 2010 5:40 am

Re: getting logged out when visiting custom page

Post by Comkid » Fri Apr 02, 2010 12:59 am

I don't see anything wrong with that, maybe it is further on in the code ;)
I ist Comkid :P

craiga
Registered User
Posts: 191
Joined: Fri Apr 10, 2009 8:14 am
Contact:

Re: getting logged out when visiting custom page

Post by craiga » Fri Apr 02, 2010 6:45 am

Comkid wrote:I don't see anything wrong with that, maybe it is further on in the code ;)
sorry for not giving the whole code. i tried to be clever and miss out uninteresting bits. here is the entire file

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'rankings.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
 $user->setup();

page_header('Predictions Matches');

$match_date_sql = ' select distinct DATE_FORMAT(m.match_date, \'%D %M %Y\') match_date
from pl_leagues l
join pl_seasons s on l.id = s.league_id
join pl_matches m on s.id = m.season_id
join pl_teams t_home on m.home_team_id = t_home.id
join pl_teams t_away on m.away_team_id = t_away.id
left join pl_predictions p on p.match_id = m.id
left join phpbb_users u on p.user_id = u.user_id
order by m.match_date desc ';
    
$match_date_result = $db->sql_query($match_date_sql);	

while ($dates = $db->sql_fetchrow($match_date_result))
{
	
    $template->assign_block_vars('fixture_dates', array(
         'MATCH_DATE' => $dates['match_date']
        ));
	
	
	$fixture_sql = ' select t_home.description home_team, t_away.description away_team, CONCAT(m.home_score,\' - \', m.away_score) score, DATE_FORMAT(m.match_date, \'%H:%i\') match_time
	from pl_leagues l
	join pl_seasons s on l.id = s.league_id
	join pl_matches m on s.id = m.season_id
	join pl_teams t_home on m.home_team_id = t_home.id
	join pl_teams t_away on m.away_team_id = t_away.id
	left join pl_predictions p on p.match_id = m.id
	left join phpbb_users u on p.user_id = u.user_id
	where DATE_FORMAT(m.match_date, \'%D %M %Y\') = \'' .$dates['match_date']. '\' 
	order by m.match_date desc
		';
	
	$fixture_result = $db->sql_query($fixture_sql);

	while ($fixtures = $db->sql_fetchrow($fixture_result))
    {
	$template->assign_block_vars('fixture_dates.fixtures', array(
            'HOME_TEAM' => $fixtures['home_team'],
			'AWAY_TEAM' => $fixtures['away_team'],
			'SCORE' => $fixtures['score'],
			'MATCH_TIME' => $fixtures['match_time']
        ));
    
	}	
	
    
	
}


$template->set_filenames(array(
	'body' => 'predictions_matches.html',
));

make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>

Comkid
Registered User
Posts: 132
Joined: Thu Mar 25, 2010 5:40 am

Re: getting logged out when visiting custom page

Post by Comkid » Fri Apr 02, 2010 7:41 am

But all parts are crucial unless you have previously appended the error, anyway on with business :P

I'm not sure I see anything wrong, can I see your HTML, or could you better explain your problem?
I ist Comkid :P

craiga
Registered User
Posts: 191
Joined: Fri Apr 10, 2009 8:14 am
Contact:

Re: getting logged out when visiting custom page

Post by craiga » Fri Apr 02, 2010 7:52 am

This is really a strange one, because i have managed to get a custom page working before.

My issue is, that if i am on the index page, or any original page, i can login and remain logged in. To confirm my login status i can no longer see the "register" option and can see "logout[xxx]".

If i click onto my custom page, then the "register" and "login" links reappear and they remain even if i go back to one of the original pages.

Just to confirm that i do not have any session issues so long as i remain on the original pages and do not visit my new custom page.

Code: Select all

<!-- INCLUDE overall_header.html -->

<!-- INCLUDE predictions_menu.html -->

<!-- INCLUDE predictions_right.html -->




<div class="predictions_left">
<h2>Matches</h2>

<div class="fixtures forumbg forumbg-table">
		<div class="inner"><span class="corners-top"><span></span></span>

		<!-- BEGIN fixture_dates -->
	  
       <h3>{fixture_dates.MATCH_DATE}      </h3>   
<table cellspacing="1" id="memberlist" class="table1">
		<!--
		<thead>
		<tr><th class="kickoff">Kickoff</th>
			<th class="home_team"></th>
			
			<th class="score">Score</th>
			<th class="away_team"></th>	
					
		</tr>
		</thead>
		-->
	  	<tbody>
		<!-- BEGIN fixtures -->
	<tr class="bg1">
	<td class="kickoff">{fixture_dates.fixtures.MATCH_TIME}</td>
		
		<td class="home_team">{fixture_dates.fixtures.HOME_TEAM}</td>
		<td class="score">{fixture_dates.fixtures.SCORE}</td>
		<td class="away_team">{fixture_dates.fixtures.AWAY_TEAM}</td>	
		
	
	</td>
	</tr>		
	<!-- END fixtures -->
		
	</tbody>
	</table> 
		
			   <!-- END fixture_dates -->

	<span class="corners-bottom"><span></span></span></div>
</div>

</div>


<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->

craiga
Registered User
Posts: 191
Joined: Fri Apr 10, 2009 8:14 am
Contact:

Re: getting logged out when visiting custom page

Post by craiga » Sat Apr 03, 2010 8:10 am

Comkid wrote:But all parts are crucial unless you have previously appended the error, anyway on with business :P

I'm not sure I see anything wrong, can I see your HTML, or could you better explain your problem?
I have managed to fix the issue, and i have a feeling that if i had fully explained my situation, it would have been easier to resolve.

I am running a test instance of my forum on my localhost, and i had not changed the cookie domain from my website URL to "locahost". I have now changed that, and it works fine.

Thanks for your help ComKid

:D

Locked

Return to “[3.0.x] MOD Writers Discussion”