Hi, I have used mod rewrite for my all dynamic URLs but in this case session value is always being dropped. Is there any way to manage sessions in mod rewrite?
jdMorgan
2:04 am on Apr 30, 2010 (gmt 0)
"Sessions" are meaningless in the context of mod_rewrite. If the session id is passed as a query string parameter appended to your URLs, then your rules must be coded to preserve that parameter -- See the [QSA] flag for RewriteRule if you are modifying the query strings in any of your rewrite rules. If you do not modify query strings in your rules, then the original query strings will pass thorough mod_rewrite without change (by default).
If the session id is passed as a cookie, then look at the realm defined for that cookie, and make sure that you are not redirecting to a domain-space for which the cookie is not configured to apply.
Jim
fahad direct
12:04 pm on May 1, 2010 (gmt 0)
Hi Jim, Thanks for your help.
I have tried php_value session.cookie_domain .domain_name by .htaccess which works fine with each other in root or subdomains but rewritten urls inside the subdomains still losing the values and many sites i have checked as these are working well without preserving the parameter.
Can you help me further in this regard.
jdMorgan
12:54 pm on May 1, 2010 (gmt 0)
You must determine (and tell us) *how* sessions are "created and maintained" on your site.
Otherwise, there is no way for us to know how they might be getting "lost."
As stated, the two usual methods are storing the session info in a client-side cookie to be passed back to the server with each client request, or passing it to the client as a query string parameter attached to the links on your pages that the client will use when requesting pages from your server.
You might also want to ask in our PHP-related forum, as the members there may have more experience with PHP-related questions. However, they will ask the same questions that I'm asking here, so you need to be prepared to answer those questions first.
Jim
fahad direct
1:16 pm on May 1, 2010 (gmt 0)
Hi Jim,
There is a subdomain abc.mydomain.com having login link for SignIn once one signs In a session is created as:
session_start(); $_SESSION['client']="store my session value";
and in my file .htaccess of the same subdomain abc i have .htaccess file having the code as:
php_value session.cookie_domain ".abc.domain.com"
I am doing mode rewrite so even it is working fine there and i can share the same session from one subdirectory to another even on root but it is being losed if i am accessing from one more inner folder inside abc subdirectory.
It works fine only upto the levels of subdirectories but if there are further folders inside, sessions are being losed.
jdMorgan
6:32 pm on May 1, 2010 (gmt 0)
Well hopefully, someone else will come along who knows the specifics of PHP sessions. I do not. Again, you may wish to ask in the PHP forum, where the members know about PHP.
However, the above may still be relevant to your problem:
make sure that you are not redirecting to a domain-space for which the cookie is not configured to apply.
Jim
fahad direct
6:37 pm on May 1, 2010 (gmt 0)
Could you please explain me in more details the meaning of the line:
make sure that you are not redirecting to a domain-space for which the cookie is not configured to apply.
g1smd
7:36 pm on May 1, 2010 (gmt 0)
If the cookie covers "xyz.domain.com" if will not be valid at "abc.domain.com" - you'd need a cookie valid for ".domain.com" to work with both.
jdMorgan
7:38 pm on May 1, 2010 (gmt 0)
Look up the definition of a cookie. When you create a cookie, it states what domain or part of a domain it applies to. For example, a cookie set by WebmasterWorld will not be sent by the browser if the user visits a different Web site such as apache.org
Google "Netscape cookie" for a start.
Jim
fahad direct
8:40 pm on May 1, 2010 (gmt 0)
Hi Jim, thanks for explaination.
.domain.com is working quite perfectly for main and sub domains but in case of a folder inside Subdirectory like abc.domain.com/subfolder, session is still losing its value.
fahad direct
8:52 pm on May 1, 2010 (gmt 0)
Also those folders I am accessing by url rewriting so might be its url rewriting issue that session being losed as it is being shared in between subdomains quite fine.