user1029468
user1029468

Reputation: 31

ASP.NET Securing Cookie on HTTP and HTTPS

I have a site that has both HTTP and HTTPS pages.

I have tried the following to make cookies secure:

In both case pages don't work with HTTP. I think above solution only works if all the pages use HTTPS.

How to resolved this puzzle?

Upvotes: 3

Views: 6381

Answers (2)

R.C
R.C

Reputation: 10565

The Question: How to resolved this puzzle , requires an analysis of the requirements and see if it would be better to use https for whole website or a combination of http & https.

Since you are also asking for an alternative in one of your above comments, I hope the below info may help you decide on alternatives.

Background:

Basically you use http for all pages that have nothing to do with sensitive data, and https on the pages that have sensitive data. Many times we don't prefer to use https for whole website as the data that travels is more and it takes time to encrypt and decrypt them , thereby adding up to the actual time it takes to load/display a page.

However, there are arguments against above common notion and you can also find encouragement to use https for your whole website. Check this: How to implement HTTPS only on part of website?

And, YES, secure cookies can only be used on https pages.

Some suggestions

Upvotes: 3

Adrian Wragg
Adrian Wragg

Reputation: 7411

The whole point of a cookie set as 'secure' is that it is only transmitted over https; the http pages will not receive a copy of it. From Wikipedia:

A secure cookie has the secure attribute enabled and is only used via HTTPS, ensuring that the cookie is always encrypted when transmitting from client to server. This makes the cookie less likely to be exposed to cookie theft via eavesdropping.

If you want to use a secure cookie, you need to ensure that all the pages use https.

Upvotes: 9

Related Questions