Jump to content


Photo

url reconstruction with php


  • Please log in to reply
6 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 September 2006 - 05:10 PM

Any site that carries a lot of information you notice you use a lot of state saving.  Sessions, cookies, get, post, all over the place.  The site I am doing, uses a lot of sessions, it uses a lot of posts, and alot of get's
It comes down to certain areas, where I am chaining together a good number of variables.
http://www.domainnam...ostset=postset1

and at some points it might get even bigger, is this going to present a problem, I heard when it get's over 255 characters, then there's a problem, because some browsers can cut some of that off.
That's under 100 all together, with all characters together including hte domain name, so I know this should be fine, but in the event, I get it 2-3 times longer than that(hasn't happened yet), what can I do, to prevent this, or what do I have to worry about with doing it like that.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 19 September 2006 - 05:16 PM

Either use a method other than 'get', or pass an 'id' and grab everything from the database based on that id ?

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 19 September 2006 - 05:28 PM

Also dont use words as your variables. Shorten them such as:
sch for school
cat for category
scat for subcategory
ps for post set.

No need to make your variables so obvious to the user what they are. That you can do in your actuall code using comments. Additionally you might want to use mod_rewrite to tidy up your urls so its like this:
site.com/schoolName/Category/subCategory/PostSet

Or just use SA's suggesstion and use another method. Such as use a temporary session variables which holds an array of School name, category, sub cat etc, Eg:
$_SESSION['school_nav'] = array('sname' => 'SchoolNameHere', 'cat' => 'categoryName' ..etc..);

Then use $_SESSION['school_nav']['sname'] to access the school name
$_SESSION['school_nav']['cat'] to access the category etc.

Use the power of arrays when dealling with masses of data dont create 1 session var for each variable. Use arrays to store multiple things in an session which relate to each other.

#4 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 September 2006 - 05:34 PM

Whether I use that right now or not, I am not sure, but the advice you gave me may prove invaluable.  So I always have a group of sessions for the user, so instead, I can create an array. like
$_SESSION['userinfo'] = array(
then create a inside the array for there username, email, ip address, last logged in date, and everything else.  Then if I have admin later I could do
$_SESSION['admin'] = array
then have all that in there
then use temporary set's of session data for other things.
So tehre would actually never be a need for get if this was true, so there has to be negatives to doing that, what negatives come with doing that, that you know of? if any.
I like that idea

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#5 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 19 September 2006 - 05:39 PM

There are uses for 'get', such as passing information from external sources. For example, if you send an activation email to someone requesting that they activate their account by clicking the link mysite.com/activate.php?id=546564

As far as I see it, there are no negative effects to using Wildteen's method, I use that method in my projects - Why pass data through the URL when you don't need too? It's both messy, and provides a small insight as to how parts of your system work.

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 19 September 2006 - 05:42 PM

Whether I use that right now or not, I am not sure, but the advice you gave me may prove invaluable.  So I always have a group of sessions for the user, so instead, I can create an array. like
$_SESSION['userinfo'] = array(
then create a inside the array for there username, email, ip address, last logged in date, and everything else.  Then if I have admin later I could do
$_SESSION['admin'] = array
then have all that in there
then use temporary set's of session data for other things.
So tehre would actually never be a need for get if this was true, so there has to be negatives to doing that, what negatives come with doing that, that you know of? if any.
I like that idea

Nothing as far as I know of. Its still the same thing just that you are using an array.

#7 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 September 2006 - 05:44 PM

I see what you mean, for now I used get, like wildteen said about cutting down the variable names. but now that I know this about sessions, I am going to start using little packets of information, as session arrays. I am goign to start passing information around that way, I am always afraid to use sessions, because I am afraid there might be something that won't work right, or something.  So I am going to put some thought into it, and start using that in my future projects, and see how the outcomes turn out.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users