5

Codeigniter - print $ Controller- & gt; Session without knowing the key?

 2 years ago
source link: https://www.codesd.com/item/codeigniter-print-controller-session-without-knowing-the-key.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Codeigniter - print $ Controller- & gt; Session without knowing the key?

advertisements

Instead of doing the following:

print $this->session->userdata('username');
print $this->session->userdata('email');
print $this->session->userdata('phone');
print $this->session->userdata('fax');
//etc...

Is there a way to do something like

foreach($this->session as $key=>$val) print $key.'-'.$val;

Or is it possible to do something like

print_r($this->session);

The reason I'm asking is because I don't know what the SESSION keys are and I also want to be able to loop through CI Session values.


$this->session is an object of course,and you can dump it using print_r or var_dump

but i recommend using this for fetching all of your session data except for flash data:

$sessionArray = $this->session->all_userdata();

Related Articles

How do I create a Domino Webin session without knowing the user's password?

In my XPages application, I want to programmatically create a session for a webuser and return a SessionId and DomAuthSessId as cookies to the browser. As far as I know, the person documents for webusers only contain a hash of the HTTPPassword and th

Parse json without knowing the keys

i am trying to parse json in java without knowing the keys and the structure of json format and save that data into the hashmap how would i cycle through the whole json format and store key and value into the hashmap {"id" : 12345, "value&q

How to get records from an object without knowing the key name?

I am struggling with the following: I have a JSON feed with my data (https://api.myjson.com/bins/1sz7s). I iterate through all ReportItems in this object through javascript / jquery. Problem I am having is I want to fetch 'records' that contain a spe

Iterate through the entire JSON object without knowing the keys

I'm attempting to perform operations (update values, delete keys, add keys, etc.) on JSON data which I do not know anything about. These items are essentially property files and not JSON data returned from an application. These files could be very di

Accessing the JSON value without knowing the key

I have a json structure as shown in the image. I want to fetch the extract value. Normally I would do $.ajax({ type: 'GET', url: 'test2.php', dataType: "json", cache: false, success: function(result) { console.log(result.query.pages[168387].extr

Resizing the hash table: how do we do it without knowing the key?

When we store only the resultant data for a key in a hashtable, how do I perform hashtable resizing? One example I can think of is to store username & password combinations. For the sake of privacy, we'd only store passwords (there can be many other

Rails checks if params values ​​are set without knowing the keys

all, I got this request: {"utf8"=>"✓", "search"=>{"name_equals"=>"", "age_equals"=>""}} What I want to check is, if name_equals or age_equals have got a value set, just by k

Get value without knowing the key in a pair associative array

There is an associative array with only one pair key=>value. I don't know it's key, but I need to get it's value: $array = array('???' => 'value'); $value = // ?? $array[0] doesn't work. How can I get it's value?You can also do either of the followi

Scala Parse Json without knowing the schema

I was wondering if there is a parser or an easy way to iterate through a json object without knowing the keys/schema of the json ahead of time in scala. I took a look at a few libraries like json4s, but it seems to still require knowing the schema ah

How to delete an object from a table numpy without knowing the index

is it possible to delete an object from a numpy array without knowing the index of the object but instead knowing the object itself? i have seen that it is possible using the index of the object using the np.delete function, but i'm looking for a way

Set string values ​​inside for without knowing the names

I am trying to find the correct way to set the string values inside the For without knowing the actual numbers. here's what i am trying to do as it was possible in vb6 but not sure using vb.net Public Class Form1 Dim iTest1 As String Dim iTest2 As St

Pass multiple parameters to the C # MVC action without knowing the exact number?

Is it possible to pass multiple parameters to C# MVC action without knowing the exactly number? For example, I could pass mywebsite.com/brands/gm/ford/fiat/dodge OR mywebsite.com/brands/gm/ford/fiat However, I don't want to have to create a route lik

How to deserialize and return JSON objects in Java with Gson without knowing the. Class a priori?

I am currently working on a thin-client application, where the communication happens through JSON-serialized message objects. Server serializes the message, sends it through a socket, client receives and deserializes. Answers happen in the same way.

How to implement a multidimensional network without knowing the number of dimensions and the elements of the network that are transmitted to you?

A SDK is returning me an array with multiple dimensions such as: int[,,] theArray = new int[2,8,12]; I need to visit each element in the array and return the value and the position of the value. I need to do this without knowing the number of dimensi

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK