URL issue (http/https)

Started by Payaa, December 25, 2012, 10:22:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Payaa

#1
Hi all!

I have SSL login in my site. Works fine if I mark the SSL in login page then click login http change https.

But I realised that if I login with SSL the links look like this:
<a href='$DEFEULTBASEURL/x.php> or <a href='$BASEURL/x.php>
the link is http://mysite.url/x.php
but if the link just
<a href='x.php>
its show https://mysite.url/x.php

But in my bittorrent.php and takelogin.php set the baseurl to https if someone login via SSL.

If I echoed the $BASEURL via https the echo just show http. LOL I hope you understand what I mean. Example I create a page this content:
echo $DEFEULTBASEURL or $BASEURL
just show http. But it must to be https if I use SSL.

Here is my code (what pdq made me) in bittorrent.php

if ($_SERVER["HTTP_HOST"] == "")
  $_SERVER["HTTP_HOST"] = $_SERVER["SERVER_NAME"];
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
  $DEFAULTBASEURL = "https://xtendtracker.info";
  $BASEURL = "https://" . $_SERVER["HTTP_HOST"];
} else {
  $DEFAULTBASEURL = "http://xtendtracker.info";
  $BASEURL = "http://" . $_SERVER["HTTP_HOST"];
}


And the code for takelogin.php

if (isset($_POST['sslbrowse']) && $_POST['sslbrowse'] == 1 && !isset($_SERVER['HTTPS']))
{
$DEFAULTBASEURL = str_replace('http','https',$DEFAULTBASEURL);
$BASEURL = str_replace('http','https',$BASEURL);
}


Why so important that to me?
Coz i someone login via http the cookie secure option is OFF but when login via https the cookie secure switch true and if someone click on a http link when he/she is ssl state the site logoff the users because the cookie only use secure connection :)

So If U dont understand (LOL) here is a pic when I'm login via SSL and echoed the $DEFAULTBASEURL what is remaining http: