Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2010
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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!

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    Sandeep2010 (04-09-2011)

  • #3
    New Coder
    Join Date
    Nov 2010
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •