session_start not work with rewritengine

This is a discussion on session_start not work with rewritengine within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I have some files php that use the session_start for archive datas in a variable $_SESSION['archive'] = $list; they not ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-03-2007
artev
 
Posts: n/a
Default session_start not work with rewritengine

I have some files php that use the session_start for archive
datas in a variable $_SESSION['archive'] = $list;

they not work more if in the file .htaccess I use this code
(for to have permalink)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]
</IfModule>

Reply With Quote
  #2 (permalink)  
Old 01-03-2007
Tyrone Slothrop
 
Posts: n/a
Default Re: session_start not work with rewritengine

On Wed, 3 Jan 2007 12:22:20 +0100, artev <mailnotspammm@notspamm.nn>
wrote:

>I have some files php that use the session_start for archive
>datas in a variable $_SESSION['archive'] = $list;
>
>they not work more if in the file .htaccess I use this code
>(for to have permalink)
>
><IfModule mod_rewrite.c>
>RewriteEngine On
>RewriteBase /site/
>RewriteCond %{REQUEST_FILENAME} !-f
>RewriteCond %{REQUEST_FILENAME} !-d
>RewriteRule . /site/index.php [L]
></IfModule>
>


I had the same problem just yesterday. According to PHP manual on
php.net, sessions are not carried when there is a redirect. Since a
mod_rewrite is on the server level, I doubt there is a simple hack
around this. I ended up using my tried and true session functions,
passing the session id in a query string and saving the session values
in a MySQL table.

I would be interested to know if there is a way to code around this
limitation.

Anyone?
Reply With Quote
  #3 (permalink)  
Old 01-03-2007
Rik
 
Posts: n/a
Default Re: session_start not work with rewritengine

Tyrone Slothrop wrote:
> On Wed, 3 Jan 2007 12:22:20 +0100, artev <mailnotspammm@notspamm.nn>
> wrote:
>
>> I have some files php that use the session_start for archive
>> datas in a variable $_SESSION['archive'] = $list;
>>
>> they not work more if in the file .htaccess I use this code
>> (for to have permalink)
>>
>> <IfModule mod_rewrite.c>
>> RewriteEngine On
>> RewriteBase /site/
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteCond %{REQUEST_FILENAME} !-d
>> RewriteRule . /site/index.php [L]
>> </IfModule>
>>

>
> I had the same problem just yesterday. According to PHP manual on
> php.net, sessions are not carried when there is a redirect. Since a
> mod_rewrite is on the server level, I doubt there is a simple hack
> around this. I ended up using my tried and true session functions,
> passing the session id in a query string and saving the session values
> in a MySQL table.
>
> I would be interested to know if there is a way to code around this
> limitation.


I user mod_rewrite in combination with sessions all the time. No problem if
they are in a cookie (and offcourse the domain stays the same...), or if
it's in the POST in an internal redirect. When the session id is in a GET
variable, add the [QSA] (query string append) flag to all your rewrites so
it will be carried over, like:
RewriteRule . /site/index.php [L,QSA]
--
Rik Wasmus


Reply With Quote
  #4 (permalink)  
Old 01-04-2007
artev
 
Posts: n/a
Default Re: session_start not work with rewritengine

> I user mod_rewrite in combination with sessions all the time. No problem if
> they are in a cookie (and offcourse the domain stays the same...), or if
> it's in the POST in an internal redirect. When the session id is in a GET
> variable, add the [QSA] (query string append) flag to all your rewrites so
> it will be carried over, like:
> RewriteRule . /site/index.php [L,QSA]



I insert my variable innera a $_SESSION (not POST or GET) ;
any idea for the solution?
QSA is for GET, but for SESSION that is?
Reply With Quote
  #5 (permalink)  
Old 01-04-2007
Rik
 
Posts: n/a
Default Re: session_start not work with rewritengine

artev wrote:
>> I user mod_rewrite in combination with sessions all the time. No
>> problem if they are in a cookie (and offcourse the domain stays the
>> same...), or if it's in the POST in an internal redirect. When the
>> session id is in a GET variable, add the [QSA] (query string append)
>> flag to all your rewrites so it will be carried over, like:
>> RewriteRule . /site/index.php [L,QSA]

>
>
> I insert my variable innera a $_SESSION (not POST or GET) ;
> any idea for the solution?
> QSA is for GET, but for SESSION that is?


I suggest you reread the PHP manual about sessions:
http://www.php.net/manual/en/ref.session.php

In short: The variables in $_SESSION never arrive at the client, and are
only on the server. The session is continued on the basis of a session-id,
which can be set by the client either by COOKIE, POST or GET. Find out how
your sessions are/should be continued.
--
Rik Wasmus


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:26 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0