[pending] Cookie insertion...

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
Peter VDD
Registered User
Posts: 140
Joined: Sun Oct 12, 2003 12:18 pm
Contact:

[pending] Cookie insertion...

Post by Peter VDD »

Hi there. I'm having a little problem in writing this mod. I'm willing insert a cookie, but it doesn't work. I get this error message and there's no cookie made. Don't say it's because of easyphp, because the standard phpbb cookies work fine. I just don't get what I did wrong.
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-7\www\forum2\includes\template.php(127) : eval()'d code:98) in c:\program files\easyphp1-7\www\forum2\includes\functions_rate.php on line ...


it's in an included function that the cookie gets saved:

Code: Select all

function store_rating($topic_id, $confirm_id)
{
	global $db;
	global $board_config;

	//
	// Here was code that does stuff (no problems were in it before I added the cookie line so it's not here)
	//

	// Now the troublezone
	$cookiename = $board_config['cookie_name'];
	$cookiepath = $board_config['cookie_path'];
	$cookiedomain = $board_config['cookie_domain'];
	$cookiesecure = $board_config['cookie_secure'];
	$da_time = time() + 31536000;

	//Ithis is the line I'm talking about, without it everything works fine.
	setcookie($cookiename . '_vote', $confirm_id, $da_time, $cookiepath, $cookiedomain, $cookiesecure);
	//Previous line needs help

	message_die('GENERAL_MESSAGE', 'Vote inserted successfully.');

}
I'm really helpless in this: I got no clue what I can do wrong, or perhaps I don't know enough about how cookies should work but anyway please help me. Thanks!
Last edited by Peter VDD on Fri Aug 06, 2004 10:45 am, edited 2 times in total.
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Post by A_Jelly_Doughnut »

Please post the .tpl file that is used currently with the MOD...that is likely the issue.
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
Peter VDD
Registered User
Posts: 140
Joined: Sun Oct 12, 2003 12:18 pm
Contact:

Post by Peter VDD »

hmm I don't think so... since it worked perfect without the cookie call

anyway here it is:

Code: Select all

<form action="{S_SEARCH_ACTION}" method="POST"><table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
	<tr> 
		<td align="left"><span class="nav">Rating topic: <a href="{U_TOPIC}" class="nav">{TOPICNAME}</a></span></td>
	</tr>
</table>

<table class="forumline" width="100%" cellpadding="4" cellspacing="1" border="0">
	<tr> 
		<th class="thHead" colspan="2" width="55%" height="25">Your Identification</th>
		<th class="thHead" colspan="2" width="45%" height="25">Your Rating</th>
	</tr>
	<tr> 
		<td class="row1" nowrap="nowrap" align="right" width="25%"><span class="gen">&nbsp;Your email:&nbsp;</span></td>
		<td class="row2"><input type="text" style="width: 170px" class="post" name="email" size="20" value="{U_EMAIL}" /></span></td>
		<td class="row1" nowrap="nowrap" align="right" width="20%"><span class="gen">&nbsp;Power level:&nbsp;</span></td>
		<td class="row2"><select class="post" name="power"><option value="0" selected="selected">Not rated</option><option value="1">1 - Very Bad</option><option value="2">2 - Bad</option><option value="3">3 - Average</option><option value="4">4 - Good</option><option value="5">5 - Very Good</option></select>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1" nowrap="nowrap" align="right"><span class="gen">&nbsp;Your confirm ID:&nbsp;</span></td>
		<td class="row2"><input type="text" style="width: 170px" class="post" name="confirm_id" size="20" value="{U_CONFIRMID}" /></td>
		<td class="row1" nowrap="nowrap" align="right"><span class="gen">&nbsp;Fun level:&nbsp;</span></td>
		<td class="row2"><select class="post" name="fun"><option value="0" selected="selected">Not rated</option><option value="1">1 - Very Bad</option><option value="2">2 - Bad</option><option value="3">3 - Average</option><option value="4">4 - Good</option><option value="5">5 - Very Good</option></select>&nbsp;</td>
	</tr>
	<tr>
		<td class="row1" nowrap="nowrap" align="right"><span class="gen">&nbsp;OR password:&nbsp;</span></td>
		<td class="row2"><input type="text" style="width: 170px" class="post" name="password" size="20" value="" /></td>
		<td class="row1" nowrap="nowrap" align="right"><span class="gen">&nbsp;Limited use:&nbsp;</span></td>
		<td class="row2"><select class="post" name="limited"><option value="0" selected="selected">Not rated</option><option value="1">1 - Very Bad</option><option value="2">2 - Bad</option><option value="3">3 - Average</option><option value="4">4 - Good</option><option value="5">5 - Very Good</option></select>&nbsp;</span></td>
	</tr>
	<tr>
		<td class="catBottom" colspan="4" align="center" height="28">{S_HIDDEN_FIELDS}<input class="liteoption" type="submit" value="Rate" /></td>
	</tr>
</table></form>
<br />
<table width="100%" border="0">
	<tr>
		<td align="right" valign="top">{JUMPBOX}</td>
	</tr>
</table>
A.I. BOT
Registered User
Posts: 1848
Joined: Thu Apr 17, 2003 11:43 pm
Location: Newfoundland, Canada
Contact:

Post by A.I. BOT »

hers how u fix it

Code: Select all

    setcookie($cookiename . '_vote', $confirm_id, $da_time, $cookiepath, $cookiedomain, $cookiesecure);
it will work fine if u make it:

Code: Select all

    @setcookie($cookiename . '_vote', $confirm_id, $da_time, $cookiepath, $cookiedomain, $cookiesecure);
Peter VDD
Registered User
Posts: 140
Joined: Sun Oct 12, 2003 12:18 pm
Contact:

Post by Peter VDD »

hmm...

there's no error anymore but the cookie still doesn't get inserted :(
markus_petrux
Former Team Member
Posts: 1887
Joined: Wed Apr 23, 2003 7:11 am
Location: Girona, Catalunya (Spain)
Contact:

Post by markus_petrux »

setcookie() works only BEFORE sending headers. So... you could try setting the cookie using javascript (within your template).

Check out this MOD, if you need a sample on managing cookies using javascript:
http://www.phpbb.com/phpBB/viewtopic.php?t=216128


HTH+
EasyMOD Standards | MOD Template Actions | MODs in Development Rules
Useful information for MOD Authors | MOD Queue Stats | Search MODs
Write SQL/DDL portable to all SQL servers supported by phpBB!
Get EasyMOD 0.3.0! | Suport al phpBB en Català!
8)
slaamp
Registered User
Posts: 29
Joined: Thu Feb 27, 2003 9:59 am
Location: here

Post by slaamp »

I noticed that cookies are not sent under windows XP if you are using http://127.0.0.1 or http://localhost
One solution is to defined a DNS name for you're machine
Right Click My Computer > Properties > Computer Name > Change > More

Once there change the part where it say's "Primary DNS Suffix of This Computer" to whatever you want, e.g. com, net,X,home,localdomain

Restart the computer and start putting comp-name.DNS Suffix
Post Reply

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