Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to save values in session?
    primarykey
    data
    text
    <p>I am working with cakephp.Recently I am facing problem in saving data in session. I have created login page which will send value to controller/action. it will receives like this.</p> <pre><code>function ajaxCall() { $this-&gt;autoRender = false; $this-&gt;layout = 'ajax'; $arrData = $this-&gt;params['url']; if(!empty($arrData)){ if($arrData['submit']=='Y'){ $userObj = new Api(); // create an instance of the user class $userInfo = $userObj-&gt;login($arrData['email'],$arrData['password']); // call the api login user methods $xml = simplexml_load_string($userInfo); $userId = $xml-&gt;message-&gt;id; if($userId != "0" &amp;&amp; $userId != ""){ $this-&gt;setCurrentUserId($userId); echo "success"; } else{ echo "no"; } } } } public function setCurrentUserId($userId) { //Is session alive //if not then redirect to session time out page //session_start(); //session_register(""); if($userId == 419 || $userId == 423){ $userId1 = $this-&gt;Session-&gt;write('userId', $userId); }else{ $userId1 = $this-&gt;Session-&gt;write('userId', $userId); } return $userId1; } </code></pre> <p>my controller contain also these line to include helpers,component</p> <pre><code> public $components = array('Session'); public $helpers = array('Html','Session'); </code></pre> <p>and in core.php file i set session as-</p> <pre><code>Configure::write('Session', array( 'defaults' =&gt; 'php', 'ini' =&gt; array('session.auto_start' =&gt; 1) )); </code></pre> <p>Please help me as i am unable to save userId in session</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. This table or related slice is empty.
 

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