Jump to content

Recommended Posts

Hello,

I am fairly proficient in PHP as well as understanding Object oriented programming. The tutorials that I can find with google talk about oop on a single page. The application that I am designing is very clean in with OO design but I cannot quite get it straight in my mind how the objects are retained throughout various pages. The objects are going to be created/filled with data from a database and it seems like too much overhead to reconstruct these objects for every page. From what i have picked up by browsing these forms is that it is standard practice to save objects in sessions, or serialize them or something. Is there good documentation or a tutorial somewhere that explains the concepts behind this?

Link to comment
https://forums.phpfreaks.com/topic/59709-solved-objects-over-multiple-pages/
Share on other sites

http://www.phpfreaks.com/forums/index.php/topic,149316.0.html

 

<?php
include('class.def.php'); // has to be before session_Start
session_start();

if (!isset($_SESSION['class_name'])) {
       $_SESSION['class_name'] = new class_name();
}else {
   $x=1;
}
$class &= $_SESSION['class_name']; // dunno if keeping the reference works but yea

if ($x==1)
    echo $class->get_var('test');

$class->set_var('test', 'Testing');

$_SESSION['class_name'] = $class;
?>

 

Unsure how savory that is, efficient or how much a toll it would take on the server. But yea I think that is what you are looking for.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.