Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your retrieve_network action, which I am assuming you call when a user reconnects to a particular service, you are overwriting the NetworkData session variable if you find 1 particular Service has been connected to:</p> <pre><code>if(isset($_GET['oauth_token'])) {...} </code></pre> <p>OR</p> <pre><code>if(isset($_GET['code'])) {...} </code></pre> <p>You set $networkData to the returned services object and then overwrite the whole session via:</p> <pre><code>$this-&gt;Session-&gt;write('NetworkData', $networkData); </code></pre> <p>Following your code, I would always check to see if an existing service is currently in session and if so do not overwrite the whole session, just add the particular data to the existing NetworkData session array:</p> <pre><code>if($this-&gt;Session-&gt;read('NetworkData.TwitterData')){ $facebookData = array( 'username' =&gt; $userinfo['username'], 'name' =&gt; $userinfo['name'], 'email' =&gt; $userinfo['email'], 'token' =&gt; $token, 'link' =&gt; $userinfo['link'], ); $this-&gt;Session-&gt;write('NetworkData.FacebookData', $facebookData); } </code></pre> <p>Note: This is just an example showing how you can achieve this. I would refactor that method with better logic for this particular situation, perhaps storing TwitterData and FacebookData in their own separate arrays as opposed to a larger more complex NetworkData array. Additionally, you can access $_GET params via $this->params['url']['paramname'] to maintain cakePHP convention. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COThat's part of the problem, if you check my settings method, after the user is redirected from my retrieve network it checks what network was added, deletes NetworkData and adds the necessary network, either TwitterData or FacebookData, so it doesn't matter if NetworkData is overwritten because it's not there to start with, it's deleted after the necessary information is extracted. Now, writing any session variable overwrites the entire session? Because my other session variables go unaltered
      singulars
    2. COBefore you get to the settings() method, the NetworkData session that currently exists is overwritten in the retrieve_network() method. Your retrieve_network action only takes into account either Twitter or Facebook, not both during the current session so if TwitterData is set in the NetworkData session, and then Facebook tries to connect, or reconnect, the whole NetworkData session is overwritten with only Facebook data. When you set the session via $this->Session->write('name', $var), that is the same as doing $_SESSION['name'] = $var. Using write() does not append to the existing session.
      singulars
    3. COThat is what's supposed to happen Anthony, after I click the Connect to Twitter or Facebook button, my callback URL points to retrieve_network() then in there the NetworkData is extracted and is redirected to setting. Now, how can I append to the session with Cake? The weird thing is that when I do write my other session variables don't get deleted. Also when the user logs in I extract his FB and Twitter data and write them separately and they are there side by side when I echo the session.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload