Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule and $_COOKIE[]

Is there a problem by working between them?

         

asantos

6:10 am on Mar 16, 2006 (gmt 0)

10+ Year Member



Is there a problem by working between RewriteRules and $_COOKIEs[]?

In my specific case, i have a permalink activation control. When it's OFF, and the website sections are called through index.php?id_section=5, the cookies inside index.php are saved correctly.

When i turn the permalinks option ON (http://www.mysite.com/contact_us/support/ .. which is id_section=5), the cookies are some-how saved, but the php script ignores their value.

Some has a solution for this?

asantos

6:15 am on Mar 16, 2006 (gmt 0)

10+ Year Member



BTW, it might help if you check the file contents:

.htaccess: *****************
RewriteEngine on
#Languages
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(_([A-Za-z]{2}))/?$ /index.php?l=$2 [L]
RewriteRule ^(.*)/_([A-Za-z]{2})/?$ /index.php?l=$2 [L]
# Sections
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ /index.php [L]

index.php ********************

if ($_GET['l']) {
# querystring (some checking here...)
$lang = strtolower($_GET['l']); }
} elseif($_COOKIE['l']) {
# cookies (some more checking here...)
$lang = $_COOKIE['l']; }
}
if (!$lang) { $lang = $config['lang']['default']; }
# lang cookie
setcookie('l', $lang, time()+$config['lang']['exp']);

asantos

4:01 pm on Mar 16, 2006 (gmt 0)

10+ Year Member



anyone?

jdMorgan

6:12 pm on Mar 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since this is a mixed Apache/PHP question, the only comment I feel qualified to make is that a cookie is saved by the client (browser) after it receives a response from the server. The client then sends that cookie back to the server with every subsequent request.

Therefore, a newly-set cookie is not available to the server until the client makes a new request.

Jim

asantos

6:34 pm on Mar 17, 2006 (gmt 0)

10+ Year Member



I already fixed it yesterday actually.
i have to set the cookie with the path argument.