Hi, My skills are not very advanced in php, and I'm currently working on a page that will allow users to complete some informations into 4 steps. Everything is ok, but I'm not usually use PHP $_SESSION and all I want to know is that if is ok to store some data into a session and than retrive it for a further step. Can somehow users encounter problems in usage of that script for various web hosts?
Hi Hefaistos, Sure you can. On my website for example when the user logins I query the database and store his data in a $_SESSION array, to avoid having to query the database at every page he views. Session support is enabled in PHP by default, I have never come across a host that doesn't support them, it would be a really strange hosting service. Hope this helps,
It's SESSIONS. Cookies can, for one, be manipulated by the client (much harder to do with sessions), cookies have a limited amount of space (normally not an issue, but the length of a cookie can't exceed a certain length) - while sessions doesn't really have that problem. If you need to store some temporary data, do use sessions.
You can use sessions to store it from page to page that's simple enough if that's all you need it to do is temp store while they're at your site. If you'd like it to be retrieved if they come back at another time though...you can store to database OR even to a simple file/folder system. If they fill out their first and last name (and if the data isn't anything private /personal/legal) and works ALSO if you don't need them to sign-up as members with user names etc. Instead a write to .txt file can be created and the .txt file created can be concatenated as $last_name . "_" . $first_name; and by entering their name when they come back again it can grab the info again. (not secure way, not for members/sign-up/etc) It's not good to use $ip anymore since IPs aren't static and change all the time now for most. Depending on your site theme you could also make a graphic image of a number panel (like an ATM / security door) and they enter a number they choose when they filled out your form. When they return they punch in the number and it retrieves their info stored. Give them two tries and time them out so somebody isn't sitting punching in numbers all day to see what they can get out of it. Or a text box "what is last name?" ..and Panel ="enter your code" and store files as text file name = $lastname . "_" . $code; example: Shmoe_123456.txt inside file is all their info from the form. (not to be used on sensitive info ..not exactly secure at all) but makes a cool ATM panel theme
Thank you all for replies. I'll use a session just to keep some temporary data from one step to another, before inserting it into the database. Also this session will not hold sensitive informations like passwords, but just some simple things like a post id and few others little things.