PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Oct 17, 2017 6:34 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Jul 14, 2015 3:55 am 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 170
Hi,

I'm going to do a small webshop (yeah i know there are loads of free ones, Im doing this just to learn php better :) ) and I want to create a code where i store most page info (settings (like page width, height, button names, title and so on)) in a database so I can easily modify the settings if I want to create a new shop later on or maybe create a framework where users can design their own shops..

So I will make the page a class with variablles like
private $keywords;
private $title;
private $buttons; ... and so on.

Each time a user clicks on a button a new page will be drawn with new content.

My question is how will I do this in the best way. I do not want to do a database call (for the page settings anyway) everytime the page loads (only the first time every session).

Should I store the values in session info after initial call to DB and check with isset later on or are there any better way to do this?

Thanks in advance.

Edit: Oh and how secure is the session info? Say I have users with a userlevel that sets permissions.. can I store userlevel in session info or is it better to do a db call for userinfo when trying to access admin functions? /edit


Top
 Profile  
 
PostPosted: Tue Jul 14, 2015 1:40 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13434
Location: New York, NY, US
Probably the best way to let users can "design their own shops" is to build an editor to customize the stylesheet. You could save the settings in a database somewhere, but it would be best to write a local stylesheet file when they save the settings. If well thought out, the user would be able to highly customize the look of the site -- yet the code and HTML would all stay the same.

_________________
(#10850)


Top
 Profile  
 
PostPosted: Thu Jul 16, 2015 11:58 am 
Offline
Forum Contributor

Joined: Wed Sep 25, 2013 4:09 am
Posts: 170
Hi and thank You,
yeah but still every time i update the page it will read either the file or db whereever i put the info (I just realized the session is stored as a temp file so it will read from a file no matter what... I guess Im really wondering if its possible to cache parts of the page like menus that will not change..
(the left and top menu will not change so only content that is going to be updated with user actions is the bottom right div)... Is it worth bothering with this at all or should I just make a css file and reload the whole page everytime a user clicks on a button or link?

Also I'm on a webhotel (one.com) so I guess its hard to cache stuff to memory.. maybe I could do it if I had a private server..

Since it will be a webshop I'm extra concerned with the safety... do You guys think the temp session files is secure enough at a place like one.com or should I do my own session functions and store the sessions in a db.. Do You have any experience with that (pro/cons).

Sorry if this is not advanced enough for this forum if so please move it to a more apropriate forum.


Top
 Profile  
 
PostPosted: Thu Jul 16, 2015 12:54 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13434
Location: New York, NY, US
hybris wrote:
Hi and thank You,
yeah but still every time i update the page it will read either the file or db whereever i put the info (I just realized the session is stored as a temp file so it will read from a file no matter what... I guess Im really wondering if its possible to cache parts of the page like menus that will not change..
(the left and top menu will not change so only content that is going to be updated with user actions is the bottom right div)... Is it worth bothering with this at all or should I just make a css file and reload the whole page everytime a user clicks on a button or link?

That was my whole point for suggesting generating a stylesheet. Since the site styles will be updated infrequently they are mainly read-only. The browser will do great caching for you since they are a separate file from you pages. This is even more helpful from database driven sites that are less cache-able.

hybris wrote:
Also I'm on a webhotel (one.com) so I guess its hard to cache stuff to memory.. maybe I could do it if I had a private server..

Since it will be a webshop I'm extra concerned with the safety... do You guys think the temp session files is secure enough at a place like one.com or should I do my own session functions and store the sessions in a db.. Do You have any experience with that (pro/cons)..
If you are doing e-commerce on a shared server then be very careful what you save in the session. Do not put credit card numbers in the session. I would actually recommend that you do not save credit card numbers anywhere on your systems -- just send them via HTTPS to the payment processor and then clear them from all variables.

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group