Php session_start hanging

Kind of a weird problem, ok, here is my setup ...

  • domain.com causes reading from iframe on sub.domain.com
  • sub.domain.com makes an ajax call to sub.domain.com/call.php
  • sub.domain.com returns ajax call to domain.com

AKA Long-Term Survey

Now everything works fine when there is no session data (I close the browser and reload the page). However, as soon as I reload the page, and their session data, call.php does start_session () and hangs there.

I have tried almost everything and can not figure it out. I tried to destroy the session by disabling all session variables, changing some ini settings, and nothing worked.

Here is the call.php code where the session data is ...

session_start(); $sql = ("SELECT userid FROM status WHERE typing = '".mysql_real_escape_string($userid)."'"); $result = mysql_query($sql); if ($result && mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); $typing_id = $row['userid']; if (!empty($typing_id)) { if (isset($_SESSION['typing2'])) { unset($_SESSION['typing2']); } } else { $typing_id = "-1"; } } else { $typing_id = "-1"; if (isset($_SESSION['typing'])) { unset($_SESSION['typing']); } } if ($_SESSION['typing'] != $typing_id && !isset($_SESSION['typing2']) || $initialize == "1") { $typing = array('typing_id' => $typing_id); } if ($typing_id == "-1") { $_SESSION['typing2'] = "-1"; } else { $_SESSION['typing'] = $typing_id; } 

Does anyone have any ideas? I thought this might be domain related, but I'm not sure.

Thanks!

+6
php session
source share
2 answers

I really found out (after hours and hours of debugging and research) that the problem is because the PHP session is being blocked. Then, when a new page loads, it will not work until the old session ends. Session_write_close () will fix it.

+7
source share

The default session store in php is cookie based. if you use this you must set the domain for your session cookie in php.ini

http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-domain

+1
source share

All Articles