Welcome! Log In Create A New Profile

Advanced

Session Variables vs other

Posted by Stephanie Werren 
Announcements Last Post
Announcement myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Session Variables vs other
May 25, 2009 11:24AM
Hi Mac,

I just would like to know more about session variables etc. as in, what is the best method to use when? Let me explain what I want to do.

If I enter information on "ADD" student details and press "ADD" button, then I go to a "COMMIT" page where I verify the user input and if successful, I proceed to add the record. If the user has made a mistake, I send them back to the input page and get them to correct their error.

1. Is it a good practice to set session variables of the user input fields so that the user does not need to re-enter the information? or
2. Is it better practice to send the input values back using href $_GET method? or, very different appraoch,
3. Should I be verifying input already on input screen before going to the commit page?

With the first method I send the user back to index.php once the add has taken place where I use session_destroy and session_unset at the top of the page to release those session variables, which works perfectly fine. I do realise that if I had not hard coded user login info in the config file, this method would no be ideal?

Hope I am making sence?

Regards
Stephanie
avatar
Mac
Re: Session Variables vs other
May 25, 2009 02:12PM
That's why sessions are so useful - because it is irritating to fill in a form, then being send back only to find you have to retype info. Normally you will be asked to use the browser's back button, which then keeps the info, but you can't trust people to do that and risk the chance of irritating them. So yes, use sessions - but you can also use cookies. With cookies the info is also captured without the person having to log in. Cookies last forever (except i people delete them smiling smiley ) so it will still work the next day. I thus use cookies more, but either is OK - it depends what your purpose is. Google for Cookies versus sessions.
Re: Session Variables vs other
May 26, 2009 01:53PM
yeah, I ended up using sessions for this as well, did some research and this seems to be the standard way to do it. Its called "sticky forms"

I also used sessions to send the error messages back to the form page. You can do the verification and database entry on the form page itself, which would eliminate the need to send the errors via session, but I started out with all my database action in one script page and I didnt want to change that.
Re: Session Variables vs other
May 27, 2009 10:52AM
Thanks! This has been a great help. That is exactly what I have done.

Just as a matter of interest, do we also need to include any form of documentation in the form of a "readme.txt" or a pdf? Or are our comments in our code enough documentation?
avatar
Mac
Re: Session Variables vs other
May 28, 2009 09:04AM
Comments are fine. Most NB is the config.php file - if you hide it in a sub-directory, it is a good idea to tell the path in a readme file placed in the root.
Sorry, only registered users may post in this forum.

Click here to login