Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting cookies when headers sent #23

Closed
adamthehutt opened this issue Oct 23, 2013 · 2 comments
Closed

Setting cookies when headers sent #23

adamthehutt opened this issue Oct 23, 2013 · 2 comments

Comments

@adamthehutt
Copy link
Contributor

Recently Raygun started tracking users by setting unique id cookies. The problem is that sometimes an error occurs after output has already started (e.g., if the error is triggered in a template). This results in another error being triggered, since you can't set cookies after output has been sent to the browser.

A pretty easy fix would be to add a conditional:

if(!headers_sent()) 

in RaygunClient.php before calling setcookie().

@fundead
Copy link
Contributor

fundead commented Oct 23, 2013

Thanks for spotting this, I've managed to repro that and the fix you suggested does indeed work. You'll find the updated master branch with the change.

@fundead fundead closed this as completed Oct 23, 2013
@CmdrKeen
Copy link
Contributor

As an aside - if you're not setting the user until after you've started streaming the content then you will lose the benefits of session tracking (which, for now, are not obvious since we're just building out support for this in the Raygun app).

While we have the guard I'd suggest setting the user earlier if you want to take advantage of what this feature will evolve to 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants