Forum Moderators: phranque

Message Too Old, No Replies

How can i figure out my website path?

Can't place a cookie without it

         

StoutFiles

6:05 am on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To set a cookie in IE, I need to have the correct path.

setcookie('var', 'hi', time()+3600, '/', 'www.example.com');

This used to work. When I changed servers, I now have GoDaddy hosting my website name and all of the files on a other server. They are linked to the domain name through the nameservers.

Anyways, '/', 'www.example.com' isn't working now so cookies won't work. I need to find the actual path.

Using the IP for example.com (74.#*$!.#*$!.#*$!) I get the Apache start up page. Okay, we're getting somewhere. Using the username example (74.#*$!.#*$!.#*$!/~example) takes to my public_html folder. Good but not great...my actual website is not in the public_html. It's in another folder, the domains folder.

*domains
*public_html

From the domains folder, there is an example.com folder, and in that folder, there is a public_html folder with my website. Confusing? Yeah, I think so too. But it's made going to my website from my IP address impossible for me, I have no idea how to navigate to my website. Any help from anyone?

coopster

1:43 pm on Jan 15, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Your web site (domain) should still be accessible from your browser at www.example.com. Cookies are set through the url path, not the filesystem path. They are two very different paths.

jdMorgan

4:57 pm on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should not have to worry about filepaths, only URLs.

The domain argument is your domain name, either en exact match like "www.example.com" or, if you wish to include subdomains, then a partial like ".example.com" -- Note the leading ".".

The path argument *can* be used to specify a url-path that restricts the cookie to a sub-set of URL-paths within your domain, for example "/public/", which would restrict the cookie to only those URLs which started with "example.com/public/". If you set it to "/", then it applies to all URL-paths in the domain, just as using the "/" URL-path in a robots.txt file does.

So what matters is the URL seen by the browser in its address bar. The mapping of URLs to filepaths inside the server, whether the server handles it in the default manner (strip off the hostname, add DocumentRoot-defined filepath) or if it modifies it because of mod_dir, mod_rewrite, or mod_alias actions, should not enter into it. URLs are *mapped* to filepaths by servers, and URLs and filepaths are only "associated" --not equivalent-- things.

You might want to define a test cookie --one not really used by your site-- and then start with the most 'open' URL specification, defining the domain as ".example.com" and the path as "/", and then look at the HTTP transactions between your server and your browser using the "Live HTTP Headers" add-on for Firefox/Mozilla browsers. Then progressively change the domain and URL-path to limit the scope of the cookie until it applies only to the subsection of the site that you want it applied to.

Remember to completely flush your browser cache before testing any newly-uploaded server config code, and whenever you want to be sure that the request is actually sent to your server instead of being served from your browser's local cache. You might even want to disable your browser's cache if you plan to do a lot of testing (set its size to zero or set the 'time to keep' to zero days), but be sure to re-enable it when done testing!

Jim