Results 1 to 11 of 11
  1. #1
    Join Date
    Feb 2007
    Posts
    25

    Red face Unanswered: Losing Session in Internet Explorer Only

    Yandy.com has a feature that allows its users to scroll through all the products in a category by clicking the "previous" or "next" button above the product picture when you are viewing a product. If you go to the Yandy.com homepage and click on any of the "featured products", you will be able to scroll through each one by clicking the "previous" or "next" buttons above the main product picture. This feature seems to work very well on the index page. The way it works is when the query is made to select all the products in a category, an array is made of all the product's "product ID's" that were just queried. After the array is made, it is added to a session (I also tried cookies and had the same issue). Then, when a user selects a product to view, the product ID for the product they just selected is searched out in the array (session) and when found, tells the program which product comes prior and next to the current product. I have done extensive testing to make absolutely sure that the array is being created correctly and does exist in the session after the page is fully loaded (and it does). The problem is that when I click on a new category or product, sometimes the session changes or disappears. Here is what I have determined so far:

    1. The problem does not occur in Firefox. It only appears to happen in Internet Explorer.
    2. We are using a mod_rewrite in the .htaccess file that allows us to use static URL names for each of our products and categories. We seem to lose the session when switching between a URL that uses a different directory. Example: The session will exist while in http://www.yandy.com/Shopping/products/category_19.asp, but then is lost when switching to http://www.yandy.com/shoes.php. I am aware that sessions and cookies usually cannot be transferred between different directories, but no matter which product (or category) they click on, the code is always using the same php script at root level.
    3. There is a session_start on the top of every page (I also tried it with If(!isset($_SESSION) and also If(session_id() == "") ) and have also tried a session_write_close at the bottom of every page (but removed it now).
    4. I have googled and tried every idea I have read without any luck.

  2. #2
    Join Date
    Feb 2007
    Posts
    25
    Oh yeah...even though I lose the previous/next button array in the session after a page reload, the session_id always remains the same.

  3. #3
    Join Date
    Feb 2007
    Posts
    25
    If you would like me to print out my session dump for you, please let me know.

  4. #4
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    What does your .htaccess mod rewrite look like? I suspect that it is using HTTP_REFERER, which is not reliable, is dependent on browser, version, and user settings, and the phase of the moon.

  5. #5
    Join Date
    Feb 2007
    Posts
    25
    #<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . router.php
    #</IfModule>
    ErrorDocument 404 /404.html

  6. #6
    Join Date
    Feb 2007
    Posts
    25
    It is weird, I have figured out that any session that I manipulate in the index.php page gets screwed up in other areas of the site. Even if they do not include index.php or visit index.php.

  7. #7
    Join Date
    Feb 2007
    Posts
    25
    Hi again,

    Since we last talked, I have determined that if I remove the session from the index.php file, it works on all of the other pages. The weird thing is that if I am viewing the category pages on internet explorer and they are working, then I add the session to the index.php page, the category pages won't work anymore, even if I don't go to the index.php (home) page. The index.php page is also not included in the the category pages in any way, so I am having trouble figuring out how it can affect them. Any suggestions would be great. Sessions are passing perfectly between all other pages.

  8. #8
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    Any chance that some of the url's have the www. and some don't?

    By default, the session.cookie_domain is none, meaning the host name where the session was started. So, a session started on a page with www.domain.com won't carry over to a page with just domain.com and visa versa.

    For session problems, either check your web server log for errors and/or turn on full php error reporting.

  9. #9
    Join Date
    Feb 2007
    Posts
    25
    Great suggestions. All the URL's do start with www., but I will definately take some time to look at the log files. When I do find the answer, I will definately post it. Thanks again!

  10. #10
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    Any URL references you have, e.g. in links , should all be relative. This means you should never change domain.
    Code:
    <a href="/path/to/blah.php">blah</a>
    Using cookies is an unreliable source of information, so do NOT use them. Clients may have them turned off, or alter them via some method.

    Also, how are you changing between pages? Are you using AJAX, or some javascript madness? Going by what you have said it would seem that the page reloads each time.

    Add in the following to each page (at the top) as an include file. It should help you determine what is changing on each page.
    Code:
    <?php
    
    session_start();
    echo "<pre>";
    print_r($_SESSION);
    echo "</pre>";
    
    ?>

  11. #11
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    It's just occured to me that you appear to be using two different scripting languages... If you first post the URL ends with .asp whereas your second url appears to end in .php . Are you using both languages?

Posting Permissions

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