0

I have a problem with passing session variables between folders. I have a working login, and several session variables are created after a successful login. The session works fine until I try to use a script that is located in a different folder or directory. All of my scripts include a login process that is activated if the session id is not found. This is what happens as soon as a script in a different directory to that containing the original login is called. Obviously the session variables are not being passed to the new directory, even though they are clearly being created for the original session.
Can anyone explain this, and suggest a solution, as it is not acceptable to be asking the user to log in every time a script is called from a different directory.

2
Contributors
5
Replies
7
Views
6 Years
Discussion Span
Last Post by jkon
0

Session , by a browser perspective , has a domain identifier. It doesn’t matter where your program is located (or in what directory) just where its domain points to. Remember that for browsers sub domains like www.sub.domain.com are different domains.

0

Well, I sort of understand, but not really. Can you explain further, or suggest a solution. I prefer to keep some related scripts in different folders to help with website organisation.

0

Well I will explain it shortly (meaning that there are more technical clarifications that I am not dealing with). Session is stored in your server as plain text (example /tmp/ sess_03eae2808a20f8aeb901aa86fb0fc2ad) there are all the data, even the objects unserialized.

Browser keeps the seesion id in the request header (If you set no other in the Cookie field … example install firebug and see in Net>Cookie> PHPSESSID=341e442d8087aafe4198ad450a359306; or something like that , that doesn’t mean that the cookie is stored in the clients cookie directory, it could be stored as well in the browser’s cookie – tokens memory).

If all the scripts – programmes that I am executing is under same domain (e.g. domain.com) and the client (browser) don’t restart then all of them should share the same session id. Of course I shouldn’t do anything with the session on my program and use in PHP just session_start(); . If one of my programs is in deferent domain url (e.g. ex1.domain.com ) then they don’t share the same session id in the browser.

0

Then it appears that there is little I can do about it apart from restructuring my web page to allow for the session activities to remain in the same folder. Thanks for the time you have given me.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.