Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-09-2011, 09:27 AM   PM User | #1
Sandeep2010
New Coder

 
Join Date: Nov 2010
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Sandeep2010 has a little shameless behaviour in the past
Exclamation PHP session ends abruptly while using mod_rewrite in .htaccess

Hello Everyone

I have a shared web hosting account. I have a login script,which after successful login,sets $_SESSION["username"] to a particular value and redirects the user to index.php. In .htaccess I have written some rules to modify the URLs of this type: index.php?id=something to index-id-something.htm .

There are links in index.php which takes the user to this URL: index-id-something.htm. Now the problem is, in index.php the session works properly but when the URL is changed to index-id-something.htm the session gets destroyed automatically! But when I type this in URL : index.php?id=something session is not destroyed. It works properly.

What could be the possible problem? Any help will be highly appreciated.

Thank You Very Much!
Sandeep2010 is offline   Reply With Quote
Old 04-09-2011, 09:44 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
but when the URL is changed to index-id-something.htm the session gets destroyed automatically!
Have you configured your server to parse php in html files? Do you have the necessary code to get SESSION in your html file as well? Does your redirect makes any www to no-www switch or its reverse?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
Sandeep2010 (04-09-2011)
Old 04-09-2011, 12:01 PM   PM User | #3
Sandeep2010
New Coder

 
Join Date: Nov 2010
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Sandeep2010 has a little shameless behaviour in the past
Quote:
Originally Posted by abduraooft View Post
Have you configured your server to parse php in html files? Do you have the necessary code to get SESSION in your html file as well? Does your redirect makes any www to no-www switch or its reverse?
Yes the problem was with the .htm extension. When I changed the extension to .php it worked again. I think session was not getting passed to html pages.

Anyways thanks for the insight.
Sandeep2010 is offline   Reply With Quote
Reply

Bookmarks

Tags
mod_rewrite, php, session

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:53 AM.


Advertisement
Log in to turn off these ads.