limitphp Posted January 7, 2009 Share Posted January 7, 2009 Will Having alot of Session Variables Slow Down Your Website? By alot I mean like 9 or 10..... or can the server handle that no problem.....and I shouldn't worry about that.... things like page numbers for pagination and other simple variables.... Quote Link to comment https://forums.phpfreaks.com/topic/139866-solved-will-having-alot-of-session-variables-slow-down-your-website/ Share on other sites More sharing options...
kenrbnsn Posted January 7, 2009 Share Posted January 7, 2009 Nine or ten is not a lot of session variables. Don't worry about it. Ken Quote Link to comment https://forums.phpfreaks.com/topic/139866-solved-will-having-alot-of-session-variables-slow-down-your-website/#findComment-731729 Share on other sites More sharing options...
.josh Posted January 7, 2009 Share Posted January 7, 2009 session data is serialized and stored in a flatfile and retrieved upon demand. Using them all at once (like in a loop or function that walks an array or whatever) would add up (as ken pointed out, 9 or 10 does not constitute 'adding up' unless the data is extremely large. Simple vars like pagination page number is nowhere near breaking point), but using them individually would not. Quote Link to comment https://forums.phpfreaks.com/topic/139866-solved-will-having-alot-of-session-variables-slow-down-your-website/#findComment-731733 Share on other sites More sharing options...
limitphp Posted January 7, 2009 Author Share Posted January 7, 2009 session data is serialized and stored in a flatfile and retrieved upon demand. Using them all at once (like in a loop or function that walks an array or whatever) would add up (as ken pointed out, 9 or 10 does not constitute 'adding up' unless the data is extremely large. Simple vars like pagination page number is nowhere near breaking point), but using them individually would not. thanks guys.... Actually, crayon, I was just reading your pagination tutorial...and I was thinking, if I store the page number in a session variable, can I assume its alot more secure, and not have to do all the isnumeric checking and greater than totalpages checking? Quote Link to comment https://forums.phpfreaks.com/topic/139866-solved-will-having-alot-of-session-variables-slow-down-your-website/#findComment-731738 Share on other sites More sharing options...
premiso Posted January 7, 2009 Share Posted January 7, 2009 session data is serialized and stored in a flatfile and retrieved upon demand. Using them all at once (like in a loop or function that walks an array or whatever) would add up (as ken pointed out, 9 or 10 does not constitute 'adding up' unless the data is extremely large. Simple vars like pagination page number is nowhere near breaking point), but using them individually would not. thanks guys.... Actually, crayon, I was just reading your pagination tutorial...and I was thinking, if I store the page number in a session variable, can I assume its alot more secure, and not have to do all the isnumeric checking and greater than totalpages checking? But if you want it to be viewable to indexing bots, it needs to be apart of the url or else they will never be able to goto the next page. Quote Link to comment https://forums.phpfreaks.com/topic/139866-solved-will-having-alot-of-session-variables-slow-down-your-website/#findComment-731744 Share on other sites More sharing options...
limitphp Posted January 7, 2009 Author Share Posted January 7, 2009 But if you want it to be viewable to indexing bots, it needs to be apart of the url or else they will never be able to goto the next page. I see...thank you. Quote Link to comment https://forums.phpfreaks.com/topic/139866-solved-will-having-alot-of-session-variables-slow-down-your-website/#findComment-731760 Share on other sites More sharing options...
.josh Posted January 7, 2009 Share Posted January 7, 2009 Well...if we were to compare session variables to GET variables in a general sense, using a session variable vs. a raw GET variable (pre-validated) would be more secure, yes. But its not necessarily more efficient. For starters, you'd just replace validation code with maintenance code, since the value would persist (as in, writing code to update the session variable). Also, you have to consider the physics of pagination. The point is to click a link, and each link causes the content to be altered. The only way your script would know that one link was clicked instead of another, is by attaching a value to it, which would be using GET, anyways. Unless you were to have the links pointing to different pages like 1.php 2.php 3.php but even then, someone can just directly type that into your url, and you'd have to be checking for that somewhere else anyways (be it custom 404 pages, mod rewrites, etc...). You could use an AJAX or FLASH interface or even make a whole bunch of mini-forms with just submit buttons, but once again, you should be validating the incoming info anyways, as even POSTed info can be altered pretty easily. Point is, session vars are generally more secure than raw GET vars in a general sense, but you can't really use just session vars with pagination, so it's kind of moot. Quote Link to comment https://forums.phpfreaks.com/topic/139866-solved-will-having-alot-of-session-variables-slow-down-your-website/#findComment-731761 Share on other sites More sharing options...
limitphp Posted January 7, 2009 Author Share Posted January 7, 2009 Well...if we were to compare session variables to GET variables in a general sense, using a session variable vs. a raw GET variable (pre-validated) would be more secure, yes. But its not necessarily more efficient. For starters, you'd just replace validation code with maintenance code, since the value would persist (as in, writing code to update the session variable). Also, you have to consider the physics of pagination. The point is to click a link, and each link causes the content to be altered. The only way your script would know that one link was clicked instead of another, is by attaching a value to it, which would be using GET, anyways. Unless you were to have the links pointing to different pages like 1.php 2.php 3.php but even then, someone can just directly type that into your url, and you'd have to be checking for that somewhere else anyways (be it custom 404 pages, mod rewrites, etc...). You could use an AJAX or FLASH interface or even make a whole bunch of mini-forms with just submit buttons, but once again, you should be validating the incoming info anyways, as even POSTed info can be altered pretty easily. Point is, session vars are generally more secure than raw GET vars in a general sense, but you can't really use just session vars with pagination, so it's kind of moot. I see. Yeah, I'm going to use the querystring and do a url rewrite. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/139866-solved-will-having-alot-of-session-variables-slow-down-your-website/#findComment-731765 Share on other sites More sharing options...
.josh Posted January 7, 2009 Share Posted January 7, 2009 Well see, that's the point. You're passing vars through the url anyway, so they have to be validated anyway, so putting it into a session var is superfluous. Quote Link to comment https://forums.phpfreaks.com/topic/139866-solved-will-having-alot-of-session-variables-slow-down-your-website/#findComment-731774 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.