Some general questions..

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

newbie12
New php-forum User
New php-forum User
Posts: 1
Joined: Sun Mar 10, 2013 2:40 am

Some general questions..

Postby newbie12 » Sun Mar 10, 2013 2:52 am

Hi,
This is not a question on a specific piece of code.Instead I want to ask general questions.
1) I will use sessions in my project.As I know,sessions may "employ" cookies if cookies are enabled by the client.Other than that,will I ever need Cookies ? I think I dont have to care about whether cookies are enabled or not , since the session will deal with it.(I dont mention that cookies are not safe) Do you think I should use cookies?

2) Filter functions. (filter_var,input etc). I use real escape string function and htmlspeciachars against both kinds of injections plus regular expressions.In this case will I need filter functions ?

3 and last) Do you think that "exceptions" are really useful or required while I can simply check for errors for specific cases?

Thanks

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Some general questions..

Postby johnj » Sun Mar 10, 2013 6:18 am

For #3:

Exceptions are in general a bit slower. They also consume more memory compared to custom error trapping code. If you think your code is slowing down then you can avoid using exceptions but exceptions are good in trapping logical errors.

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Some general questions..

Postby johnj » Sun Mar 10, 2013 6:28 am

For #2:

For preventing sql injections use PDO and prepared statements. For simple html content, yes htmlspachars or strip_tags is ok but for not so simple html content it is better to use a lib like html purifier because filters are mostly validators than something that prevents injection.


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 3 guests