[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.
<?php // RAY_https_only.php
// DEMONSTRATE HOW TO RESTRICT A SCRIPT SO THAT IT ONLY RUNS BEHIND HTTPS
// IF NOT HTTPS
// CONSTRUCT THE HTTPS URL WE WANT, PRESERVING GET VARS
// BAIL OUT WITH 301 AND LOCATION
header("HTTP/1.1 301 Moved Permanently");
// ELSE WE ARE ALREADY IN HTTPS - START SESSION FOR HTTPS ONLY IN ALL SUBDIRECTORIES AND ALL SUBDOMAINS
$x = explode('.', strtolower($_SERVER["HTTP_HOST"]));
$y = count($x);
if ($y == 1) // MAYBE 'localhost'?
$cookie_domain = $x;
else // SOMETHING LIKE 'www2.atf70.whitehouse.gov'?
// USE THE LAST TWO POSITIONS TO MAKE THE HOST DOMAIN
$cookie_domain = '.' . $x[$y-2] . '.' . $x[$y-1];
$sess_name = session_name();
// MAN PAGE: http://us2.php.net/manual/en/function.setcookie.php
setcookie($sess_name, session_id(), NULL, '/', $cookie_domain, TRUE, TRUE);
Open in new window
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.