mod_rewrite killing my php sessions
Moderator: General Moderators
mod_rewrite killing my php sessions
Hi
I have used mod_rewrite to transform a url such as news-article.php?news_id=1 to news-article1.html
however in doing so mt sessions do not work on these urls.
I currently have a member session and when i get to this page it appears as if they have logged out.
Does anybody have any experience of this problem and know a way to fix it? - I should add that i'm only having this problem in IE
Thanks in advance
I have used mod_rewrite to transform a url such as news-article.php?news_id=1 to news-article1.html
however in doing so mt sessions do not work on these urls.
I currently have a member session and when i get to this page it appears as if they have logged out.
Does anybody have any experience of this problem and know a way to fix it? - I should add that i'm only having this problem in IE
Thanks in advance
- Buddha443556
- Forum Regular
- Posts: 873
- Joined: Fri Mar 19, 2004 1:51 pm
i'v justed tested again and it is working with no session id in the url, however when it doesnt work a session id appears in the url.
how would I implement cookies
my current login script looks like this:
thanks for your help
how would I implement cookies
my current login script looks like this:
Code: Select all
function login($username, $password)
{
global $SITE_PATH;
if(isset($_SESSION['valid_user']))
{
$login = 'Y';
//$_SESSION['valid_user'] = $member_id;
$member_id = $_SESSION['valid_user'];
$row = member_query($member_id);
$last_login = $row['last_login'];
$title = $row['title'];
$firstname = $row['firstname'];
$surname = $row['surname'];
$street1 = $row['street1'];
$town = $row['town'];
$county = $row['county'];
$postcode = $row['postcode'];
$country = $row['country'];
$region = $row['region'];
$digest_format = $row['digest_format'];
//$member_id = $row['member_id'];
if(empty($title) || empty($firstname) || empty($surname) || empty($street1) || empty($town) || empty($county) || empty($postcode) || empty($country) || empty($region) || empty($digest_format))
{
//if first login or user has not completed details redirect to their account page
if($_SERVER['REQUEST_URI'] != "/accounts/change-details.php?member_id=$member_id")
{
//only redirect if they are not on that page at present
header('location: '.$SITE_PATH.'accounts/change-details.php?member_id='.$member_id.'');
}
}
}
else {
if ($username && $password)
{
//they have tried to login in
if (login_query($username, $password))
{
$member_id = get_memberid_query($username);
$_SESSION['valid_user'] = $member_id;
$row = member_query($_SESSION['valid_user']);
$last_login = $row['last_login'];
$title = $row['title'];
$firstname = $row['firstname'];
$surname = $row['surname'];
$street1 = $row['street1'];
$town = $row['town'];
$county = $row['county'];
$postcode = $row['postcode'];
$country = $row['country'];
$region = $row['region'];
$digest_format = $row['digest_format'];
$show_email = $row['show_email'];
update_lastlogin_query($member_id); //update when member last logged in
if(empty($last_login) || empty($title) || empty($firstname) || empty($surname) || empty($street1) || empty($town) || empty($county) || empty($postcode) || empty($country) || empty($region) || empty($digest_format))
{
//if first login or user has not completed details redirect to their account page
if($_SERVER['REQUEST_URI'] != "/accounts/change-details.php?member_id=$member_id")
{
//only redirect if they are not on that page at present
header('location: '.$SITE_PATH.'accounts/change-details.php?member_id='.$member_id.'');
}
}
$login = 'Y';
}
else {
//unsuccessful login
//print '<p>You could not be logged in</p>';
//return false;
$login = 'N';
}
}
}
return $login;
}thanks for your help
- Buddha443556
- Forum Regular
- Posts: 873
- Joined: Fri Mar 19, 2004 1:51 pm
You would need to fix these runtime configuration settings: session.use_cookies, session.use_only_cookies and, session.use_trans_sid. Either in your php.ini file, htaccess file or using ini_ set() [before you start the session].
I don't use mod_rewrite (actually what I use is Zend's rewrite router, but same difference) for "hiding that I use php". I use it because these:jyhm wrote:Question: is mod_rewrite that important? How much of a risk is it that people know that you use php? I ask because I am ignorant.
http://www.mywebsite.com/articles/how_to_eat_a_carrot
http://www.mywebsite.com/profile/jyhm
is a lot more user-friendly, easily remembered, better looking, and easier to read / share with others and generally more convenient than these:
http://www.mywebsite.com/articles.php?a ... t_a_carrot
http://www.mywebsite.com/profile.php?ac ... rname=jyhm
- jyhm
- Forum Contributor
- Posts: 228
- Joined: Tue Dec 19, 2006 10:08 pm
- Location: Connecticut, USA
- Contact:
You know, I think I understand.
www.loose-weight.com/OMG_you_are_a_major_fat_@ss
would look better as:
www.loose-weight.com/you_can_do_it
www.loose-weight.com/OMG_you_are_a_major_fat_@ss
would look better as:
www.loose-weight.com/you_can_do_it
my rewrite rules are as below:
Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteRule news/(.*).html$ /news/news-article.php?news_id=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule tj/back-issue(.*)\.html$ /tj/tj-issue.php?tj_id=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule tj/(.*).html$ /tj/news-article.php?news_id=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule recruitment/job(.*)\.html$ /recruitment/job.php?job_id=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule recruitment/(.*).html$ /recruitment/results-list.php?jobs_cat=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule directories/events/training-event(.*)\.html$ /directories/events/event.php?event_id=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule directories/events/(.*).html$ /directories/events/category.php?event_catname=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule directories/venues/venue(.*)\.html$ /directories/venues/venue.php?ven_id=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule directories/venues/(.*).html$ /directories/venues/location.php?county=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule directories/suppliers/supplier(.*)\.html$ /directories/suppliers/supplier.php?sup_id=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule directories/suppliers/(.*).html$ /directories/suppliers/category.php?supp_catname=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule whitepapers/paper(.*)\.html$ /whitepapers/paper.php?paper_id=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule whitepapers/(.*).html$ /whitepapers/results.php?cat_name=$1-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
... Is that all in a single .htaccess file?
You only need the options and the rewrite engine statements once...
Try this, I just added [L,QSA] to the end of each rule (and got rid of the extra junk).
You only need the options and the rewrite engine statements once...
Try this, I just added [L,QSA] to the end of each rule (and got rid of the extra junk).
Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteRule news/(.*).html$ /news/news-article.php?news_id=$1 [L,QSA]
RewriteRule tj/back-issue(.*)\.html$ /tj/tj-issue.php?tj_id=$1 [L,QSA]
RewriteRule tj/(.*).html$ /tj/news-article.php?news_id=$1 [L,QSA]
RewriteRule recruitment/job(.*)\.html$ /recruitment/job.php?job_id=$1 [L,QSA]
RewriteRule recruitment/(.*).html$ /recruitment/results-list.php?jobs_cat=$1 [L,QSA]
RewriteRule directories/events/training-event(.*)\.html$ /directories/events/event.php?event_id=$1 [L,QSA]
RewriteRule directories/events/(.*).html$ /directories/events/category.php?event_catname=$1 [L,QSA]
RewriteRule directories/venues/venue(.*)\.html$ /directories/venues/venue.php?ven_id=$1 [L,QSA]
RewriteRule directories/venues/(.*).html$ /directories/venues/location.php?county=$1 [L,QSA]
RewriteRule directories/suppliers/supplier(.*)\.html$ /directories/suppliers/supplier.php?sup_id=$1 [L,QSA]
RewriteRule directories/suppliers/(.*).html$ /directories/suppliers/category.php?supp_catname=$1 [L,QSA]
RewriteRule whitepapers/paper(.*)\.html$ /whitepapers/paper.php?paper_id=$1 [L,QSA]
RewriteRule whitepapers/(.*).html$ /whitepapers/results.php?cat_name=$1 [L,QSA]