Hi I am having problem with sessions in my site , the session data gets lost randomly . My site is on a shared hosting so i can't edit php.ini ( i am on hostgator ) Please help me
Too vague, I can only guess what can be happening... They may lose their session cookie or something obscure, try adding SID to the end of all links. Dan
I would've assumed he had locked sessions to an IP... Obviously it's a risk if he hasn't, and the user goes posting their session link on forums etc. Dan
Hi After lot of testing i think i have identified the bug but i don't know how to resolve it . The problem occurs when i login the site and click a link ( an external link which opens in new TAB ) from my account and when i come back to the current TAB ( my site ) the session data is lost and i am redirected to the login page , this happens in both IE and firefox and i am using session_start(); on every page but still i get this problem
You will definitely loose session when your exit page (url) before going to some other site is different than returning url. e.g. If you were browsing page www.yourdomain.com/somepage.php and went to some external site. And after some time you come to the same page or different page but without www i.e. yourdomain.com/otherpage.php. The reason behind is that the session was created for www.yourdomain.com, but you came back on yourdomain.com. If you use www with the url, your problem will be solved. You can solve this problem by setting session cookie domain using session_set_cookie_params().
Hi , thanks for the reply but the problem is not with using "www" or not ( my site's url remain the same as it was before either www or without it ) . the problem occurs when i click on a link in my account to some other site which opens in new tab and when i come back to my current tab , the session data is lost .
It is a strange problem. I have domains hosted on hostgator and got no problem with session. You should ask your friend to browse your web from his computer.
Problem solved after a lot of googling about my problem i found this The session variable is still lost when navigating even if I change $setting or $_SESSION['setting']. If you assign a session subscript/key to the same name as a variable, the session variable will be volatile and lost upon navigating. For example, if passing a setting that you want in $_SESSION, don't do this: <? $setting = $_REQUEST['setting']; if (!empty($setting)) $_SESSION['setting'] = $setting; ?> Instead, rename $setting or $_SESSION['setting']. Code (markup): I was also having the same problem , after renaming some of my variables my problem got solved BTW thanks for your inputs
yeah, that's the first thing that comes to my mind either, probably beacuse of the register_globals the variables you use through the page, variables you get from get, post, cookie or session, all mix up, replace one another... check register_globals
I don't have access to php.ini bcos i am on a shared hosting . btw thanks for identifying the problem and its solution
Create a php file containing the below code, save it in your web root and access it with browser <?php phpinfo(); ?> In the output you will be able to find register_globals.