This topic is locked
[SOLVED]

 get $_SESSION variable for searchfor

12/5/2012 2:28:57 PM
PHPRunner General questions
G
gudon author

Hi,
I am trying to get the $_SESSION variables for searchfor.
On my list page, I have a basic search box. When a user enters a search phrase, the project will save it to a $_SESSION variable (I guess).

I want to call it from the view page, before display event. According to the Help manual, I have tried:
$searchfor=$_SESSION["cars_searchfor"] //cars is the table name.
but, it returned null.
If I print out all SESSION variables (print_r ($_SESSION)), part of the display looks like this:
[cars_advsearch] => O:12:"SearchClause":17:{s:6:"_where";a:10:{s:15:"cars_simpleSrch";

s:9:"my phrase";s:26:"carssimpleSrchTypeComboOpt";s:8:"Contains";s:26:"carssimpleSrchTypeComboNot";

b:0;s:28:"carssimpleSrchFieldsComboOpt";s:0:"";s:13:"cars_srchType";s:3:"and";

s:15:"cars_srchFields";a:0:{}s:22:"cars_srchOptShowStatus";b:0;s:24:"cars_ctrlTypeComboStatus";

b:0;s:21:"carssrchWinShowStatus";b:0;s:11:"cars_search";i:0;}s:5:"tName";s:4:"cars";

s:15:"searchFieldsArr";a:5:{i:0;s:2:"ID";i:1;s:4:"name";i:2;s:4:"date";i:3;s:5:"phone";i:4;s:7:"zipcode";....
What I need is to get my search phrase (the red colored text) through calling a $_SESSION variable.
Could you please help? Thanks a lot.

C
cgphp 12/10/2012
$obj = unserialize($_SESSION['cars_advsearch']);

echo $obj->_where['cars_simpleSrch'];
G
gudon author 12/10/2012


$obj = unserialize($_SESSION['cars_advsearch']);

echo $obj->_where['cars_simpleSrch'];



Thanks, Cristian. It works like a charm.