Welcome Guest, Not a member yet? Register   Sign In
Saving session data
#1

[eluser]dgriffter[/eluser]
Hi,

I'm saving a session variable in a view file using the following code:

$this->session->set_userdata('message', 'bling bling bling');


I then try to access the saved message later in the same view file like so:

<p>&lt;?php $this->session->userdata('message'); ?&gt;</p>



I'm getting an empty paragraph... can anyone please help?

Thanking you kindly,

Dgriffter
#2

[eluser]gtech[/eluser]
I don't think the &lt;?php tags will display content you need the &lt;?= tags

eg

Code:
<p>&lt;?= $this->session->userdata('message'); ?&gt;</p>

the php tags will execute php code but not display it.
#3

[eluser]wakextreme[/eluser]
[quote author="gtech" date="1196139256"]I don't think the &lt;?php tags will display content you need the &lt;?= tags

eg

Code:
<p>&lt;?= $this->session->userdata('message'); ?&gt;</p>

the php tags will execute php code but not display it.[/quote]

gtech is right you either need to do as he suggested and use the short tags or you can add echo.

Code:
<p>&lt;?php echo $this->session->userdata('message'); ?&gt;</p>
#4

[eluser]dgriffter[/eluser]
The echo treatment surely worked.... thank you, you guys/girls are fantastic.

Very much appreciated,

Dgriffter




Theme © iAndrew 2016 - Forum software by © MyBB