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
tecktalkcm0391
DevNet Resident
Posts: 1030 Joined: Fri May 26, 2006 9:25 am
Location: Florida
Post
by tecktalkcm0391 » Fri Aug 14, 2009 3:22 pm
I have a class and in it there is a function that makes a cookie:
Code: Select all
class login {
function setCompanyId($company_id){
setcookie('company_id', $company_id, 2592000 + time() );
}
}
And it never seems to be created. Any ideas why? And how to fix it?
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Aug 14, 2009 3:25 pm
What does
show?
Also, try setting the cookie with the path and domain name as well. It shouldn't make any difference, but you never know...
tecktalkcm0391
DevNet Resident
Posts: 1030 Joined: Fri May 26, 2006 9:25 am
Location: Florida
Post
by tecktalkcm0391 » Fri Aug 14, 2009 3:53 pm
The output shows only
Code: Select all
Array ( [token] => fd3f90c46f59b53832578ed188d5156b )
Token in the PHP Session Name.
Any more ideas, I added the path and domain name too, no luck.
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Aug 14, 2009 3:58 pm
Have you got error reporting turned on? Are you calling this function before anything is output to the page?
tecktalkcm0391
DevNet Resident
Posts: 1030 Joined: Fri May 26, 2006 9:25 am
Location: Florida
Post
by tecktalkcm0391 » Fri Aug 14, 2009 4:04 pm
I had ob_start running which hide the header errors, but I am getting "headers already sent by" message. Is there anyway to find out where its coming from, cause the line it says, it tells me it the setcookie() line. Anyway to work around it?
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Aug 14, 2009 4:08 pm
What's the exact error?
tecktalkcm0391
DevNet Resident
Posts: 1030 Joined: Fri May 26, 2006 9:25 am
Location: Florida
Post
by tecktalkcm0391 » Fri Aug 14, 2009 7:35 pm
A line of code above the line with the cookie was causing the error. Thanks though
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Aug 14, 2009 11:23 pm
Ahh right. Cool. No problem.