0

I want to set two ini directives by ini_set():

ini_set("session.cookie_httponly","1");

and

if(/*cookies disabled*/){
    ini_set("session.use_only_cookies", "0");
    $url.=htmlspecialchars(SID);
}

Will it work to set it just on the first page (especially the first one) or should I provide it on every page of my project?

And if I should use it on every page: Is there any other option to change configuration settings if I haven't got the access to the php.ini and PHP configuration files on the server? Could I set it in other way? (e.g. by using another PHP function or .htaccess)

Thibault
  • 1,566
  • 15
  • 22
aleskva
  • 1,644
  • 2
  • 21
  • 40

1 Answers1

2

If you want those settings to apply to every page request you need that code to be present on every page. Placing it in one file and then using require() to include it would be the best way to handle it in your situation.

You can try to set these values in your htaccess file but many web hosts disable this.

John Conde
  • 217,595
  • 99
  • 455
  • 496
  • I found, that just FastCGI installed PHP doesn't accept .htaccess settings, thanks. I think I'll rather try to create `config.php` file from @Niet the Dark Absol recommendation – aleskva May 22 '14 at 13:08
  • Well, I checked whether my hosting uses PHP as FastCGI and not, so finally, .htaccess is the best option for me, many thanks – aleskva May 22 '14 at 13:29