In Symfony 2, I want to check if the current request is secure (SSL) or not, and I know that we can do that with pure php such as checking the $_SERVER['https']. However, I wonder if there is any Symfony method/helper that already helps us to determine that?
Asked
Active
Viewed 5,386 times
1 Answers
7
Symfony\Component\HttpFoundation\Request has isSecure method. You can use it in your controller in the following way:
if ($this->getRequest()->isSecure()) {
// ...
}

Molecular Man
- 22,277
- 3
- 72
- 89
-
2In my case this function was not working correctly, so I used the one described at http://stackoverflow.com/questions/1175096/how-to-find-out-if-you-are-using-https-without-serverhttps – Tomasz Kuter Feb 20 '15 at 19:11