Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

addHeader memberprofiles


Go to End


4 Posts   2258 Views

Avatar
nicanor

Community Member, 15 Posts

13 October 2011 at 2:46am

Edited: 13/10/2011 2:48am

I set with

$this->response->addHeader("Content-Type", "text/html");

the Content-Type in my Page.php

with ajax request i load some other sites, wich give back just some inner_Html, but also as sites in silverstripe BE.

I have integrated memberprofiles and changed the Login form with

Object::useCustomClass('MemberLoginForm', 'CustomLoginForm');
Authenticator::register_authenticator('CustomAuthenticator');
Authenticator::set_default_authenticator('CustomAuthenticator');
Authenticator::unregister_authenticator('MemberAuthenticator');

in my config file. Everything works fine. But when put the add Header line in my Page.php i got the error

Fatal error: Call to a member function addHeader() on a non-object in /home/mm/public_html/proj/mysite/code/Page.php on line 57

when i try to reach mysite/Security/login

When i comment the line everythings fine.

i need to put this line in Page.php. I tried it former to but it above in php's in Layout. But since i got the requests with ajax it's nescessary in page.php

Suggestions?

Thanks.

Avatar
igorbi

Community Member, 3 Posts

16 October 2013 at 10:19pm

Edited: 16/10/2013 10:21pm

Have almost identical issue when trying to set:

$this->response->addHeader('X-Frame-Options', 'SAMEORIGIN');

in controller (init method). It shows white screen when accessing login form, otherwise it is working (when accessing pages as anonymous visitor).

Same response from apache: Call to a member function addHeader() on a non-object ...

Avatar
kindleman.com.au

Community Member, 70 Posts

1 May 2014 at 4:29pm

same here. Would be great to get a fix for this.

$this->response->addHeader('X-Frame-Options', 'SAMEORIGIN');

This is recommended here: http://doc.silverstripe.com/framework/en/topics/security

but if you put it in the page controller init the error is:

Call to a member function addHeader() on a non-object

Avatar
kindleman.com.au

Community Member, 70 Posts

1 May 2014 at 4:33pm

I guess an obvious work around is

if(is_object($this->response)){
$this->response->addHeader('X-Frame-Options', 'SAMEORIGIN');
}