Jump to content

Recommended Posts

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.  Even though I lose the previous/next button array in the session after a page reload, the session_id always remains the same.

5.  I have googled and tried every idea I have read without any luck.

 

Link to comment
https://forums.phpfreaks.com/topic/72820-losing-session-in-internet-explorer/
Share on other sites

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.

I actually have a standalone script of a survey I created, allows you to add questions by way of text files and displays all the survey questions and keeps track and so forth.

 

I did have a problem with sessions initally since I wanted them to last for 5 minutes only. Here's the code that fixed it:

 

ini_set('session.gc_maxlifetime',"300");//in seconds, maximum session lifetime
ini_set('session.gc_probability',1);//leave this alone, it means that the '1' divided by the divisor gives the percentage of removing sessions, in this case: 100%
ini_set('session.gc_divisor',1);
ini_set('session.cookie_lifetime',"300");//maximum cookie lifetime
session_save_path('/home/tmp');//I saved all my sessions outside my public_html folder (it's different for diff servers)
session_start();

 

And then start the session, you could use this code, and set sessions to last for however long you want. In order for sessions not to be cleared when the user closes the browser, as is the default method, make sure the cookie is set at the same time as session maxlifetime

Thanks kratsg,

 

        I have actually spent the last few days playing with all of those settings and none of them seem to help.  I have also tried replacing the sessions with cookies and the same thing happens.  The session ID always stays the same, but I lose the variables in the sessions only in internet explorer and only if I add the variables into the session on the index.php file.  Very weird.

I actually had the opposite problem with mine. Maybe we can switch problems xD

 

On this blackjack game I have (where I got the above code from as well). Sometimes when they end the game, the sessions don't clear out (even though I nullify all session variables, I unset each session variable, then implement session destroy). For some odd reason, they'll get the same cards again even though the session cleared itself out xD So yeah.. I was able to fix it by re-defining the session maxlifetime to be 1 minute (since who takes that long to play the game?) and it actually resolved the problem (I also added an if/else check while clearing out, added a wait time for the conditional).

Cool....I'm glad you found a solution that worked for you.  Usually if I just do:

setcookie( session_name() ,"",0,"/");

session_destroy();

 

that takes care of them, but I have seen some strange situations.  If you think of any other suggestions for my problem, let me know.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.