1

I am using 7digital API in a PHP project. Here is my code to calling API:

print_r($_SESSION);   

$requestUrl = "http://api.7digital.com/1.2/release/details?oauth_consumer_key=" . SEVEN_DIGITAL_CONSUMER_KEY . "&country=$CountryCode&releaseid=" . $wishlistArray[$i]['release7id'] . "&imageSize=33";
$response = simplexml_load_file($requestUrl);

print_r($_SESSION); 

It's working fine but here is a problem like:

If i press refresh button one time then session variable is not unsetting means (i can access session data after API calling code) but press again refresh button before loading previous refresh action then session data will be unset automatically.

Means if i press more than one time refresh button continuously then session data automatically destroyed.

What may be reason?

For one time refreshing it's working fine. If i removed XML loading code then it's working fine to more than one time refreshing or single time refreshing.

Martin C
  • 395
  • 1
  • 7
  • 21

2 Answers2

2

It's a fairly well-known problem/bug.

See here to get full a full explanation and complete solution.

MarcoS
  • 17,323
  • 24
  • 96
  • 174
  • Sessions store "XML" just fine. XML is just a string of text. Apparently the *`SimpleXMLElement` class* is buggy when being serialised/unserialised or simply doesn't support it, which is something of a different problem. – deceze Dec 10 '13 at 12:35
  • My link to php reference manual does clearly explain the problem... – MarcoS Dec 10 '13 at 13:11
  • Yes, I just want to make sure your general statement "sessions don't like sorting XML" doesn't sound as bad as it does. – deceze Dec 10 '13 at 13:12
  • You are right... Just edited my answer... :-) – MarcoS Dec 10 '13 at 13:18
-1

include session_start(); at the top of your script

Neeraj Kumar
  • 1,058
  • 1
  • 9
  • 22