Jump to content

[SOLVED] Quick question


adamjones

Recommended Posts

I have a subdomain for an administration panel on my website. The idea is the user logs in on the normal website, and if they type in the subdomain, they will be directed to the admin panel. On the admin panel, it checks if the user is logged in, and if not directs them back to the website. If they are logged in, it checks their rank, and if their rank is over 1, it allows them access.

 

Only problem I'm having is related to sessions I think. If I'm logged in, and go to the admin panel, using the subdomain, it just directs me to the website, as if I wasn't even logged in. But, if I go to the real URL of the admin panel, instead of the subdomin, it works perfectly?..

 

Hmm..

 

Here is the code for my admin panel;

 

<?php
session_start();
if(!session_is_registered(name)){
header("location:http://www.mysiteblahblah.co.uk");
}
{
if($_SESSION['rank'] > 0){
header("location:admin.php"); }
else {
header("location:http://www.mysiteblahblah.co.uk");
}
}
?>

 

Eg:

 

www.mysite.com/secure/house-keeping/index.php

 

will work...

 

www.subdomain.mysite.com

 

wont.

Link to comment
https://forums.phpfreaks.com/topic/146190-solved-quick-question/
Share on other sites

Ok well I'm about to sound really wrong on this, but I don't think your sessions can cross domains.

 

For example:

 

www.mydomain.website.com

 

and

 

www.website.com

 

They are both 2 different domains.....

 

But it's the same website, the subdomain is just a redirect to the same website, just /secure/blahblah

 

Hmm..?

Well you can test this out easily.

 

Run the same program/website and instead of using your subdomain, just make it a regular path on your server like:

 

www.mywebsite.com/admin

 

www.mywebsite.com/somethingelse

 

 

If your code works that way, then we can probably say it's a subdomain thing...

 

Again, I could be way off though...

 

 

Well you can test this out easily.

 

Run the same program/website and instead of using your subdomain, just make it a regular path on your server like:

 

www.mywebsite.com/admin

 

www.mywebsite.com/somethingelse

 

 

If your code works that way, then we can probably say it's a subdomain thing...

 

Again, I could be way off though...

 

 

 

Done, it works perfectly. Thank's for your help.

Guess I'll just have to wave goodbye to my subdomain.

:(

Well you can test this out easily.

 

Run the same program/website and instead of using your subdomain, just make it a regular path on your server like:

 

www.mywebsite.com/admin

 

www.mywebsite.com/somethingelse

 

 

If your code works that way, then we can probably say it's a subdomain thing...

 

Again, I could be way off though...

 

 

 

Done, it works perfectly. Thank's for your help.

Guess I'll just have to wave goodbye to my subdomain.

:(

 

 

Wow I was actually right? LOL....

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.