Jump to content

Session remember things it should NOT....


leesiulung

Recommended Posts

This is really odd behavior, but follow me with this as I'm a little baffled.

 

I use sessions to store information in $_SESSION. However, variables that are not in $_SESSION that I define myself is also remember between pages in the same session.

 

What gives?

 

Is $error_msg a some kind of global variable?

 

So, I might have two pages, let say page1.php and page2.php. They both use the variable $error_msg and session_start();

 

However, page2.php remembers what $error_msg contained at the end of page1.php....

 

Link to comment
Share on other sites

maybe a book would help!

 

Perhaps, although I do have an older book I use for reference.

 

It is just frustrating as I spend so much time trying to figure out oddities. I mean, sure I have syntax and run-time errors that are my fault. Symptoms like the one above though is not something I expect.

 

I assumed, and correct me if I am wrong, that all variables declared unless in session variables should be obliterated at the end of the PHP script. That is how it is in other languages I dealt with....

Link to comment
Share on other sites

Yeah, I read that posts about the headers.

 

I think I figured out the 'issue' as in probably one of PHP "great" features it automatically links variables in $_SESSION['varname'] with variables $varname. Thus, when I think I'm using two different variables it is actually both the same!!!

 

So far I have nothing good to say about PHP and my prior suspicion about it being a terrible language is confirmed. I hope the language dies, because it does nothing but breed terrible programmers with its lax syntax and lack of foretought in language design.

 

I appreciate your guys help and please don't take my frustration as something directed to any of you.

Link to comment
Share on other sites

Yeah, I read that posts about the headers.

 

I think I figured out the 'issue' as in probably one of PHP "great" features it automatically links variables in $_SESSION['varname'] with variables $varname. Thus, when I think I'm using two different variables it is actually both the same!!!

 

So far I have nothing good to say about PHP and my prior suspicion about it being a terrible language is confirmed. I hope the language dies, because it does nothing but breed terrible programmers with its lax syntax and lack of foretought in language design.

 

I appreciate your guys help and please don't take my frustration as something directed to any of you.

 

Not really, you are the one who needs to stop using it. Who agree?

Link to comment
Share on other sites

I agree that PHP is useful and powerful. Also the user support is tremendous, far beyond anything I have seen in a scripting language except for Perl back in the day. However, PHP has too many shortcomings in my opinion. Many "features" of PHP that should never have been introduced. There are also certain shortcuts/features should only be turned on if the user specifically requested it, like the alias of $_SESSION['error_msg'] and $error_msg.

 

I spend so much time figuring out oddities that most other languages do not have for a reason. Some of those things can be powerful, but it should not ASSUME that the user is aware of them. People aware of them will turn them on.

 

The lack of understanding will always make people run and hide, if you want to do as little work as possible and hate a challenge then maybe VB8 is better for you.

 

I program in Servlets/JSP and frequently do stuff in ColdFusion. JSP is definetly takes more work to perform the same things as in PHP, so it is not necessary the amount of work that I dislike about PHP. It is the amount of work trying to figure out the languages oddities. JSP is definetly more advanced and has a steeper learning curve, but it does not assume cr*p to the same extent as PHP.

 

Try using more reasonable variable names, you have millions of choices.

 

Keeping same variable names on each page that has same meaning and perform same function keeps code consistent and is good programming practice. That is a language feature problem, not a coding design problem.

 

 

Just because you hate it doesn't mean everyone else does. PHP is a very useful language for me. If you get fluent in it, it'll be a less of a pain for you. Trust me. PHP is powerful.

 

I never suggested that 'everyone else' hates PHP. Rather I was saying it promotes bad programming practices as evident that it does not require variable declaration, obscure shortcut notations, no datatype or namespaces. I have seen functions in the API that changed its return value between PHP versions... wtf. That is numero uno BAD PROGRAMMING PRACTICE in the API.

 

So yes, I have a lot of gripes with PHP. I am forced to however learn it as a lot of people use it.... unfortunately.

 

I'm actually suprised I didn't get flamed (more)....

Link to comment
Share on other sites

The lack of understanding will always make people run and hide, if you want to do as little work as possible and hate a challenge then maybe VB8 is better for you.

 

I program in Servlets/JSP and frequently do stuff in ColdFusion. JSP is definetly takes more work to perform the same things as in PHP, so it is not necessary the amount of work that I dislike about PHP. It is the amount of work trying to figure out the languages oddities. JSP is definetly more advanced and has a steeper learning curve, but it does not assume cr*p to the same extent as PHP.

 

 

I'm actually suprised I didn't get flamed (more)....

 

I have used ALOT of programming languages, and ColdFusion is one i gave up, i personally this its useless,

as for turning things on an off.. erm ok so PHP is highly configureable.. how is that a bad thing!!

 

PHP is much different than ColdFusion or JSP. In terms of scalability, PHP has an advantage, but it loses a few features that some developers miss (which is why there are efforts to create application servers for PHP).

 

PHP scales well because Apache scales well because the Web scales well. PHP doesn’t try to reinvent the wheel; it simply tries to fit into the existing paradigm, and this is the beauty of it.

 

oh an flaming is the act of sending or posting messages that are deliberately hostile and insulting, who flamed you ?

Link to comment
Share on other sites

I have used ALOT of programming languages, and ColdFusion is one i gave up, i personally this its useless,

as for turning things on an off.. erm ok so PHP is highly configureable.. how is that a bad thing!!

...

 

I think ColdFusion has its issues, such as extra whitespaces everywhere, but it does not promote bad programming practice. I would not recommend ColdFusion unless it was already in use. However, I still think it is a step above PHP in terms of language design.

 

PHP is much different than ColdFusion or JSP. In terms of scalability, PHP has an advantage, but it loses a few features that some developers miss (which is why there are efforts to create application servers for PHP).

 

PHP scales well because Apache scales well because the Web scales well. PHP doesn’t try to reinvent the wheel; it simply tries to fit into the existing paradigm, and this is the beauty of it.

 

PHP has its issues as mentioned above. In my opinion, they are far to serious to be considered for large sites. I do not know about PHP's or Apache's ability to scale nor do I know about ColdFusion ability to scale. However, from experience JSP is far the best language I have come across for scalability in terms of users. If interrested, I urge you to do some research as JSP is considerably faster than it used to be. Do not take ColdFusion built on Java as the benchmark for JSP as there are additional translations going on between CFM and Java.

 

I have not worked on large sites with PHP, but remember when people talked about MySpace switching from ColdFusion (I think) to PHP and it was considerably faster.

 

That said, I'm not sure what you mean by scalability? In terms of what, is PHP/Apache scalable?

 

oh an flaming is the act of sending or posting messages that are deliberately hostile and insulting, who flamed you ?

 

That is why I have 'more' in parentheses as it is nobody so far has been directly hostile or insulting

Link to comment
Share on other sites

the fact remains i am a better programmer in PHP than JSP (dame i must really suck at JSP), but theirs a few things to consider on any project, ie timescale, *scalability, cost (normally linked to timescale), and of course user requirements..

 

an personally,

timescale = php (i'm quicker at it)

scalability = (if coded correctly then PHP)

cost = well lamp means only hardware.. so PHP

 

i started on ASP and then ASP.NET, i still have to code in these at work but in my own time on my own projects i used PHP,

 

but it boils down to one thing

 

personal preference!

 

*scalability, aka Load scalability

A distributed system should make it easy for us to expand and contract its resource pool to accommodate heavier or lighter loads. or the ease with which a system or component can be modified to fit the problem area.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.