Storing Data From Database into Sessions ...?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
skp
Forum Newbie
Posts: 9
Joined: Fri Jul 10, 2009 7:58 am

Storing Data From Database into Sessions ...?

Post by skp »

hi,
I need to know how to store data ( result set) retrieved from the database into the sessions so that, i need to avoid going to database fetch each time. Is there any possibility to store such huge data in sessions..?
Thanks in advance
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Storing Data From Database into Sessions ...?

Post by jackpf »

Yeah, but sessions are pretty much like a flat file database...so there's not really much point tbh.

Well, I don't think there is anyway.
User avatar
genconv
Forum Commoner
Posts: 34
Joined: Sun Jul 05, 2009 9:27 am

Re: Storing Data From Database into Sessions ...?

Post by genconv »

Storing data in a session is very simple:

Code: Select all

 
<?php
session_start();
$_SESSION['data'] = $array_of_data_from_db;
 
but if you want to store huge data you must remember that there is something like max session size :)
skp
Forum Newbie
Posts: 9
Joined: Fri Jul 10, 2009 7:58 am

Re: Storing Data From Database into Sessions ...?

Post by skp »

skp wrote:hi,
I need to know how to store data ( result set) retrieved from the database into the sessions so that, i need to avoid going to database fetch each time. Is there any possibility to store such huge data in sessions..?
Thanks in advance
thanks for ur reply
Post Reply