views:

56

answers:

1

Hi I am intersted in learning more about the SECURE parameter of the function session_set_cookie_params

can you tell me how to utilize this properly? if this function is executed on a page that is not secure (but on a server that does have SSL) will it somehow send it securely or do I have to force SSL on the page this function is executed from on my own?

thank you

+1  A: 

It means that the client will only send that cookie through a secure (HTTPS) connection. This means you'll have to forward the user to a secure URL in order for the cookie to get sent to the server.

You can set a secure cookie through an insecure connection, though you obviously should not (otherwise the value of the cookie may be sniffed). Since a secure cookie can be changed by an insecure connection, you cannot trust that the cookie value was not corrupted by a third party that intercepted and changed the contents of an insecure HTTP request to your site. Therefore, depending on how you're using the secure cookie, you may need to validate its contents.

Artefacto
im wondering if im already on a secure page, wont the cookie be automatically sent securely rendering that parameter redundant?
chicane007
@chicane No, because the user may be tricked into visiting your site via a non-secure connection, thus exposing the cookie contents to anyone who's listening.
Artefacto