APIs & Integrations

catalinsendsms
Participant

My session is destroyed inside the IFrame of CRM

I try to make an IFrame extension. I need to use the session variable to store some values. When I submit my form, the session gets rested and I lost all previously stored data. I made a simplified version of my code which will reproduce the bug.

 

<?php
session_start([
    "use_strict_mode" => true,
    "use_only_cookies" => true,
    "use_trans_sid" => false
]);
if ($_SERVER['REQUEST_METHOD'] === "GET") {
    $_SESSION['test'] = 'sas';
    error_log("GET:" . json_encode($_SESSION));
?>
    <form method="POST">
        <button type="submit">Send your message</button>
    </form>
<?php
} elseif ($_SERVER['REQUEST_METHOD'] === "POST") {
    error_log("POST:" . json_encode($_SESSION));
}
?>

 

When the IFrame is opened I get this: GET:{"test":"sas"} but when I press submit I get this: POST:[]  in my errors file

0 Upvotes
3 Replies 3
amit-hs
Participant

My session is destroyed inside the IFrame of CRM

Hey @catalinsendsms I'm not yet sure how sessions/cookies are maintained with IFrames embedded in HubSpot pages. I've onlly tested a few simpler use-cases (non-secure sites). Also, my knowledge of PHP is zero, and can't be of any help there. 😥

0 Upvotes
catalinsendsms
Participant

My session is destroyed inside the IFrame of CRM

Any help @dennisedson or @amit-hs ?

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

My session is destroyed inside the IFrame of CRM

Hey @amit-hs while you are in the community, maybe you could helop @catalinsendsms here 😀

0 Upvotes