Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

SESSIONS

 
   Database Forums (Home) -> PHP RSS
Next:  Upload Progressbar  
Author Message
jantox

External


Since: May 02, 2006
Posts: 2



(Msg. 1) Posted: Mon May 08, 2006 1:15 am
Post subject: SESSIONS
Archived from groups: comp>lang>php (more info?)

Good day,

We have some Java programmers in our software dev, and they are
pressuring us to use Sessions to store data and use that Session to get
query data. They say that it is ok since it is like Entities in Java. I
am baffled as a .NET programmer, we tend to avoid using sessions and
instead use DataSet, is there any equivalent of dataset in PHP?

 >> Stay informed about: SESSIONS 
Back to top
Login to vote
Jerry Stuckle

External


Since: Aug 11, 2004
Posts: 1367



(Msg. 2) Posted: Mon May 08, 2006 11:26 am
Post subject: Re: SESSIONS [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

wrote:
> Good day,
>
> We have some Java programmers in our software dev, and they are
> pressuring us to use Sessions to store data and use that Session to get
> query data. They say that it is ok since it is like Entities in Java. I
> am baffled as a .NET programmer, we tend to avoid using sessions and
> instead use DataSet, is there any equivalent of dataset in PHP?
>

One thing to remember is with PHP information does not survive the page unless
it is stored externally.

Sessions are a very convenient and safe way to store the data. Data is stored
locally on the server and only the session ID is stored in the client's browser.
PHP handles the sessions quite well; all you need to do is place
session_start() at the beginning of each page where you wish to use sessions.
If no session has been previously started, a new one is created. Otherwise the
existing session is used.

Then you can set and retrieve data from the $_SESSION superglobal array, just
like any other superglobal, i.e.

a.php
session_start();
$_SESSION['counter'] = 1;

b.php
session_start();
$myvar = $_SESSION['counter'];

Quick, easy and convenient.

Now - I wouldn't use sessions to store a megabyte of data or more, because the
entire array would be read into memory. This could cause performance problems.
But if you need to store that much perhaps you need to rethink your structure
a little more. A database might be more reasonable, depending on your needs.





--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.TakeThisOut@attglobal.net
==================

 >> Stay informed about: SESSIONS 
Back to top
Login to vote
Erwin Moller

External


Since: Sep 11, 2003
Posts: 137



(Msg. 3) Posted: Mon May 08, 2006 11:59 am
Post subject: Re: SESSIONS [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

wrote:

> Good day,
>
> We have some Java programmers in our software dev, and they are
> pressuring us to use Sessions to store data and use that Session to get
> query data. They say that it is ok since it is like Entities in Java. I
> am baffled as a .NET programmer, we tend to avoid using sessions and
> instead use DataSet, is there any equivalent of dataset in PHP?

Hi,

I would NOT advise storing a complete resultset in your session.
If you store it simply in your session, you store a resourceID, which is
unusable next invocation of any script using the same session.

You can however store an array-representation of the resultset in your
session.

If you use ADODB as a databaseabstractionlayer, you can do the following:
$res = $conn->Execute($SQL)->GetArray();

Beware however that big resultsets stored in session is asking for
performancetroubles.

Also, if you want to see your session:
<pre>
<? print_r($_SESSION); ?>
</pre>

Regards,
Erwin Moller
 >> Stay informed about: SESSIONS 
Back to top
Login to vote
Dikkie Dik

External


Since: Sep 15, 2005
Posts: 19



(Msg. 4) Posted: Tue May 09, 2006 11:23 pm
Post subject: Re: SESSIONS [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

A session is like a shopping cart or a theater's wardrobe. It is a piece
of storage assigned to a visitor.
What you put in a session are mostly things that should remain on the
server, because you do not want the visitor to be able to mess with it.
For instance, a login function can return a role, that determines access
rights. You can store this role in the session, but you do not want to
store it in a hidden form variable in HTML.
Sessions in PHP are not fundamentally different from those in .NET.
There is a session array that can be filled with anything serializable
and in some cases more.

So you do not have to store every query result, but a session can be a
good place to store intermediate results that are needed later. Sessions
are the "trick" that make a bunch of stateless http-calls look like a
continuously running web application.

Best regards

wrote:
> Good day,
>
> We have some Java programmers in our software dev, and they are
> pressuring us to use Sessions to store data and use that Session to get
> query data. They say that it is ok since it is like Entities in Java. I
> am baffled as a .NET programmer, we tend to avoid using sessions and
> instead use DataSet, is there any equivalent of dataset in PHP?
>
 >> Stay informed about: SESSIONS 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
new to sessions - escuse me the keyboard in Tallin airport i work on http://panbaltica.com/docman/action_popup.php i have one session_start which causes 2 errors i send headers not to cache the page then the session_start - it should be elsewhere it is a test - anyway, ...

New to Sessions 2 - Hi! I started a thread app 2 weeks ago and redlied to that, but it seems to be so low in the list, that it will not be seen. My problem - I need to transfer the sesstion to another page? say page1.php goes to page2.php ( <a href="page2.php&quo...

URL masking when using PHP sessions. - We have a huge PHP e-commerce site that relies totally on PHP sessions and cookies. We need to create a demo version of the site for potential clients to use that does NOT show the original URL in the browser, but we can't just simply copy the site and..

sessions and security - Hi Everyone- I was reading a few posts about sessions and security, and it seems that the best way to address sessions security is to require authentication every time the user needs to get to sensitive data (or protect the session data with SSL). In..

Strange things with sessions - Hi, I have problems with this following script that is called from page1.php and then go back to the calling page. But it seems the SESSION values are not saved properly, for in the calling page they are empty. This is the script: <?php..
   Database Forums (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]