?
Solved

test secure connection

Posted on 2005-03-03
5
Medium Priority
?
330 Views
Last Modified: 2008-03-10
is there a way with php to check if the page is being viewed on a secure connection?

e.g. https vs http

thanks
0
Comment
Question by:qwertq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 11

Accepted Solution

by:
matt_mcswain earned 500 total points
ID: 13450027
One way:

if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'))
0
 

Author Comment

by:qwertq
ID: 13450091
great!

and i assume i can use (below) accordingly.
(!isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'on'))

where do you get $_SERVER['HTTPS'] from? i do not see it reflected in the manual http://us2.php.net/reserved.variables
0
 
LVL 11

Expert Comment

by:matt_mcswain
ID: 13450147
It a webserver variable. I believe it's a mod_ssl thing.
So your best bet is to create a phpinfo() page and view it using https, to make sure you have it.
0
 
LVL 11

Expert Comment

by:matt_mcswain
ID: 13450175
Oh, and if you're doing your test that way, don't require both conditions; so

(!isset($_SERVER['HTTPS']) || ($_SERVER['HTTPS'] != 'on'))
0
 
LVL 11

Expert Comment

by:matt_mcswain
ID: 13450249
Funny enough, it is documented on the link you posted; in the contributed comments anyway. :)
Scroll down about three-quarters down the page or do a search for "https".
There's also another solution posted-->$_SERVER['SERVER_PORT']==443
But really just check your phpinfo().
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question