Domain Masking and Session Variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tbasher15
Forum Newbie
Posts: 6
Joined: Tue May 26, 2009 8:46 am

Domain Masking and Session Variables

Post by tbasher15 »

I have a domain that is masked with godaddy.com and when I access my website with that domain name, the session variables do not work. If I access the website directly with the standard URL, everything works great.

From what I can tell, essentially every click that takes place on the website with the domain masked, a new session ID is created. So when the first page is accessed, a session id is created and my variables get set, as they should. But as soon as I click to another page, the session id changes and thus my variables no longer exist.

Any ideas on how to stablize that session ID and thus save my session variables?

Thanks!
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Domain Masking and Session Variables

Post by Eric! »

Is your browser blocking cookies from the godaddy.com domain?
tbasher15
Forum Newbie
Posts: 6
Joined: Tue May 26, 2009 8:46 am

Re: Domain Masking and Session Variables

Post by tbasher15 »

No.

Thanks for the reply.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Domain Masking and Session Variables

Post by Eric! »

Then there is probably something changing in the server php configuration. Check the environment variables for each condition via ini_get() for session data/path/config/etc. Otherwise you'll have to experiment and/or get godaddy to tell you what is going on.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Domain Masking and Session Variables

Post by John Cartwright »

I'm not exactly what you mean by your site is "masked by go-daddy". Are you sure this masking utility correctly saving the cookies and passing them on in subsequent requests?
tbasher15
Forum Newbie
Posts: 6
Joined: Tue May 26, 2009 8:46 am

Re: Domain Masking and Session Variables

Post by tbasher15 »

Godaddy allows you to forward a domain to any URL without pointing to DNS Servers.

For example: http://www.myexample.com << can be forwarded to >> http://www.someothersite.com/directory/file.php so that when you type in myexample.com it opens up the file.php. Without masking, this address would show in the address bar of your browswer (http://www.someothersite.com/directory/file.php). Godaddy allows you to "Mask" the domain name so that when file.php is accessed with http://www.myexample.com, (http://www.myexample.com) appears in the address bar. Godaddy also allows you to enter page title and I think even meta tags when you mask which supersedes the title on the page.

Without session variables, I don't know what else I can use to maintain state and pass variables from page to page. POST and GET will not work in this scenerio. Are there any others?
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Domain Masking and Session Variables

Post by Eric! »

If godaddy is actually acting as a proxy for your site, then how it behaves is completely under their control. If Post and Get don't work either then there is no way to pass data between pages that I can think of. Perhaps you could do something on the client side with javascript.
tbasher15
Forum Newbie
Posts: 6
Joined: Tue May 26, 2009 8:46 am

Re: Domain Masking and Session Variables

Post by tbasher15 »

The Solution:

I had a header("Location: http://www.someothersite.com/Directory/nextfile.php") redirect on the landing page that the godaddy.com domain name (myexample.com) was directed to.

From what I can tell, some broswers must have been confused and creating two sessions. One for the masked domain name (myexample.com) and one for (someothersite.com).

Once I changed the header call to: header("Location: ../Directory/nextfile.php") it started working. I also added a session_write_close(); above the header redirect line. I read somewhere that helps to secure the session variables before the redirect.

Thanks for all your input!
Post Reply