RE: [PHP] SESSION problem
At 12:55 AM +0100 8/20/08, Ford, Mike wrote: Content-Type: text/plain Content-length: 1998 Been on holiday, so coming to this party a bit late, but On Sat 16/08/2008 15:06 Stut wrote: On 16 Aug 2008, at 14:46, tedd wrote: At 2:11 PM +0100 8/16/08, Stut wrote: Ahh, I see the problem. You've never been able to use numbers as keys at the root level of the $_SESSION array. It's not a bug, it's just the way it is. I've just checked the documentation and can't find an obvious reference to this limitation which is kinda annoying. Well at http://www.php.net/manual/en/session.examples.php there's a big fat Note at the top of the page which includes the following: The keys in the $_SESSION associative array are subject to the same limitations as regular variable names in PHP, i.e. they cannot start with a number and must start with a letter or underscore.. Yeah, but that's no fair -- you read the documentation. :-) Seriously, however, the thing that bothered me wasn't the limitations in keys, that's understandable, but rather if you do use a numeric index, then all the legal session variables declared after that incident no longer work. Imagine having ten session variables working and then adding another with a numeric index between sessions five and six declarations. I can see the session with the numeric index not working, but why would sessions six through ten stop? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SESSION problem
Been on holiday, so coming to this party a bit late, but On Sat 16/08/2008 15:06 Stut wrote: On 16 Aug 2008, at 14:46, tedd wrote: At 2:11 PM +0100 8/16/08, Stut wrote: Ahh, I see the problem. You've never been able to use numbers as keys at the root level of the $_SESSION array. It's not a bug, it's just the way it is. I've just checked the documentation and can't find an obvious reference to this limitation which is kinda annoying. Well at http://www.php.net/manual/en/session.examples.php there's a big fat Note at the top of the page which includes the following: The keys in the $_SESSION associative array are subject to the same limitations as regular variable names in PHP, i.e. they cannot start with a number and must start with a letter or underscore.. [ -- SNIP -- ] Let me play the age-card -- in every language I've programmed in for the last 43 years an array can have numeric indexes -- except php's SESSION. I wish I understood the reason why it's like this but I've never looked into the session extension in that level of detail, but I doubt such a limitation would exist if there was not a very good reason for it. One word suffices here: register_globals! Or, if that doesn't suffice: if register_globals is turned on, all the $_SESSION entries are automatically registered as global variables -- so any numeric indexes will obviously be invalid and will disappear. For consistency's sake, PHP enforces the restriction even with register_globals off. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries Learning Innovation, C507, Civic Quarter Campus, Leeds Metropolitan University, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: [EMAIL PROTECTED]Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
Re: [PHP] SESSION problem
At 8:02 PM -0700 8/15/08, VamVan wrote: Tedd, I think according to PHP manual. Session_start() must be the first line in the code. Dont worry it will remember your session until you close the browser and also it wont duplicate it. VamVan: Yes, I thought that as well and practiced it for years, but that's not true -- read the manual. In any event, that's not the problem here. The problem here is can I use a variable within a $_SESSION[] declaration? Like so: $_SESSION[$var] Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
On 16 Aug 2008, at 12:36, tedd wrote: At 8:02 PM -0700 8/15/08, VamVan wrote: Tedd, I think according to PHP manual. Session_start() must be the first line in the code. Dont worry it will remember your session until you close the browser and also it wont duplicate it. VamVan: Yes, I thought that as well and practiced it for years, but that's not true -- read the manual. In any event, that's not the problem here. The problem here is can I use a variable within a $_SESSION[] declaration? Like so: $_SESSION[$var] I haven't really been following this thread but using a variable like that is perfectly valid. $_SESSION is no different to any other array during the processing of your script, the only difference is that it's stored between requests. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
session_start() doesn't have to be the first line in the code, but it does have to occur before ANY content sent to the browser, and this includes any headers as well. Generally speaking, it does no harm to have it as the first line of your PHP code Ash www.ashleysheridan.co.uk ---BeginMessage--- At 8:02 PM -0700 8/15/08, VamVan wrote: Tedd, I think according to PHP manual. Session_start() must be the first line in the code. Dont worry it will remember your session until you close the browser and also it wont duplicate it. VamVan: Yes, I thought that as well and practiced it for years, but that's not true -- read the manual. In any event, that's not the problem here. The problem here is can I use a variable within a $_SESSION[] declaration? Like so: $_SESSION[$var] Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
Hello Tedd, it seems to be a naming problem. You may not use a numeric value for a variable name to store in $_SESSION. By assigning it to $_SESSION, you get a Notice: Unknown: Skipping numeric key 1 in Unknown on line 0 and in your second script a Notice: Undefined offset: 1 in yourpath\index1.php on line XX - whatever line it was in your script If you define $_SESSION['var'.$i] = $i; or $_SESSION[$i.'var'] = $i; or even $_SESSION[$i.'.1'] = $i; the $_SESSION won't forget your vars on the way to script 2. But it's a bit strange, that you can use your numeric keys in script 1. I tried with other Superglobals like $_POST and $_COOKIE and they seem to accept numeric variable names. So, is that a php bug? But as the docu says A valid variable name starts with a letter or underscore, I think you can not complain about it. Cheers Sabine tedd schrieb: Hi gang: Arrggg -- what the heck is going on? I can't get anything to pass via SESSION -- what's wrong? Here's the example -- (all the code is there): I populate the $_SESSIONs here. http://www.webbytedd.com/b2/session-test/index.php If you click Proceed to Step 2, you'll see that nothing is passed. Now, where did I go wrong? Cheers, tedd PS: I've tried this on two different servers and get the same results. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
At 12:40 PM +0100 8/16/08, Stut wrote: On 16 Aug 2008, at 12:36, tedd wrote: The problem here is can I use a variable within a $_SESSION[] declaration? Like so: $_SESSION[$var] I haven't really been following this thread but using a variable like that is perfectly valid. $_SESSION is no different to any other array during the processing of your script, the only difference is that it's stored between requests. -Stut Stut: I was hoping you would join in. But I solved the problem and found a surprising result. The result is you cannot use a number as an index in a $_SESSION, like so: $a = 20; $_SESSION[$a] = good morning'; -- won't work But you can use: $a = a20'; $_SESSION[$a] = good night'; -- will work Furthermore, if you do make that mistake, all other $_SESSION variables declared AFTER the incident will cease to work. Isn't that interesting? Here's an example: http://www.webbytedd.com/b2/session-test1/index.php The code is at the bottom of the page. Please tell me that you didn't know this, for if you do, it will make my day. On the other hand, if you tell me where I it wrong, it will still make my day. :-) Always a pleasure listening to your thoughts and advice. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
At 2:09 PM +0200 8/16/08, Sabine Richter wrote: Hello Tedd, it seems to be a naming problem. You may not use a numeric value for a variable name to store in $_SESSION. By assigning it to $_SESSION, you get a Notice: Unknown: Skipping numeric key 1 in Unknown on line 0 and in your second script a Notice: Undefined offset: 1 in yourpath\index1.php on line XX - whatever line it was in your script If you define $_SESSION['var'.$i] = $i; or $_SESSION[$i.'var'] = $i; or even $_SESSION[$i.'.1'] = $i; the $_SESSION won't forget your vars on the way to script 2. But it's a bit strange, that you can use your numeric keys in script 1. I tried with other Superglobals like $_POST and $_COOKIE and they seem to accept numeric variable names. So, is that a php bug? But as the docu says A valid variable name starts with a letter or underscore, I think you can not complain about it. Cheers Sabine Sabine: You hit the nail right on the head. I discovered that fact this morning and posted an answer already. Here's the demo: http://www.webbytedd.com/b2/session-test1/index.php I read everything I could find about sessions, but didn't come across: A valid variable name starts with a letter or underscore To the contrary, this is only what I found: Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores Where did you see that? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
Hello Tedd, tedd schrieb: At 2:09 PM +0200 8/16/08, Sabine Richter wrote: Hello Tedd, it seems to be a naming problem. You may not use a numeric value for a variable name to store in $_SESSION. By assigning it to $_SESSION, you get a Notice: Unknown: Skipping numeric key 1 in Unknown on line 0 and in your second script a Notice: Undefined offset: 1 in yourpath\index1.php on line XX - whatever line it was in your script If you define $_SESSION['var'.$i] = $i; or $_SESSION[$i.'var'] = $i; or even $_SESSION[$i.'.1'] = $i; the $_SESSION won't forget your vars on the way to script 2. But it's a bit strange, that you can use your numeric keys in script 1. I tried with other Superglobals like $_POST and $_COOKIE and they seem to accept numeric variable names. So, is that a php bug? But as the docu says A valid variable name starts with a letter or underscore, I think you can not complain about it. Cheers Sabine Sabine: You hit the nail right on the head. I discovered that fact this morning and posted an answer already. Here's the demo: http://www.webbytedd.com/b2/session-test1/index.php Yes, our mails overlaped each other (Do you say that in english? My english is not the best.) I read everything I could find about sessions, but didn't come across: A valid variable name starts with a letter or underscore To the contrary, this is only what I found: Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores Where did you see that? My citation is just a part of what you found. By the way: I tried your initial code and I had no problem with the variable declared after the numeric ones. (your $_SESSION['test']). I tried on a Version 5.2.5 an Win XP. Cheers, Sabine Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
On 16 Aug 2008, at 13:20, tedd wrote: At 12:40 PM +0100 8/16/08, Stut wrote: On 16 Aug 2008, at 12:36, tedd wrote: The problem here is can I use a variable within a $_SESSION[] declaration? Like so: $_SESSION[$var] I haven't really been following this thread but using a variable like that is perfectly valid. $_SESSION is no different to any other array during the processing of your script, the only difference is that it's stored between requests. -Stut Stut: I was hoping you would join in. But I solved the problem and found a surprising result. The result is you cannot use a number as an index in a $_SESSION, like so: $a = 20; $_SESSION[$a] = good morning'; -- won't work But you can use: $a = a20'; $_SESSION[$a] = good night'; -- will work Furthermore, if you do make that mistake, all other $_SESSION variables declared AFTER the incident will cease to work. Isn't that interesting? Here's an example: http://www.webbytedd.com/b2/session-test1/index.php The code is at the bottom of the page. Please tell me that you didn't know this, for if you do, it will make my day. On the other hand, if you tell me where I it wrong, it will still make my day. :-) Ahh, I see the problem. You've never been able to use numbers as keys at the root level of the $_SESSION array. It's not a bug, it's just the way it is. I've just checked the documentation and can't find an obvious reference to this limitation which is kinda annoying. I would question why you would want to do such a thing. Whenever I use sessions (which is rare these days) I tend to organise the data with some sort of context, which generally doesn't end up using pure numbers. If you really want to use numeric indices in your session array you can do so by adding a second level, i.e. $_SESSION['vars'] = array(20 = 'good night'); -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
At 2:11 PM +0100 8/16/08, Stut wrote: Ahh, I see the problem. You've never been able to use numbers as keys at the root level of the $_SESSION array. It's not a bug, it's just the way it is. I've just checked the documentation and can't find an obvious reference to this limitation which is kinda annoying. I agree. But what I find even more annoying is: 1) No error is generated. 2) The error prohibits ALL other SESSION variables legally declared after the error to stop working! In other words, if you make the mistake of using a numeric index for a SESSION, then ALL legal SESSIONs declared after that will stop working. And, what makes this even more frustrating is that ALL SESSIONs declared before will continue to work. IMO, it would be better if once you screwed it up, then everything would stop working. So, let's say this happens (as it did to me last year), you have a set of scripts that work fine and in one script you use a numeric index for a SESSION. Once that statement is encountered in the flow of the program, ALL other SESSION variables declared after that don't work anymore. In one sequence of scripts everything worked fine and in a different sequence only some things work. That was maddening and I never knew what it was until now. And, no mention of this problem in the documentation. This should give you a bit more ammunition for your I never use SESSIONs for anything argument. --- you further stated I would question why you would want to do such a thing. You have never moved data between arrays?!? Come on, I'm sure you have done it before. It's an old habit I have filling arrays -- I never had any problems using numbers before. This works: for ($i; $i10; $i++) { $things[$i] = $other_things[$i]; } I was looking at SESSION the same way -- after all it IS called an array. Let me play the age-card -- in every language I've programmed in for the last 43 years an array can have numeric indexes -- except php's SESSION. Thanks for your comments. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
At 2:45 PM +0200 8/16/08, Sabine Richter wrote: Yes, our mails overlaped each other (Do you say that in english? My english is not the best.) Sabine: Your English is fine -- much better than my de for certain. By the way: I tried your initial code and I had no problem with the variable declared after the numeric ones. (your $_SESSION['test']). I tried on a Version 5.2.5 an Win XP. That's interesting. Let's make sure we're talking about the same thing here. This is the demo: http://www.webbytedd.com/b2/session-test1/index.php In my browser Step 1 shows: SESSION[20] = good morning SESSION[test2] = good night In Step 2: Neither are there. Is that what you see? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
On 16 Aug 2008, at 14:46, tedd wrote: At 2:11 PM +0100 8/16/08, Stut wrote: Ahh, I see the problem. You've never been able to use numbers as keys at the root level of the $_SESSION array. It's not a bug, it's just the way it is. I've just checked the documentation and can't find an obvious reference to this limitation which is kinda annoying. I agree. But what I find even more annoying is: 1) No error is generated. 2) The error prohibits ALL other SESSION variables legally declared after the error to stop working! In other words, if you make the mistake of using a numeric index for a SESSION, then ALL legal SESSIONs declared after that will stop working. And, what makes this even more frustrating is that ALL SESSIONs declared before will continue to work. IMO, it would be better if once you screwed it up, then everything would stop working. So, let's say this happens (as it did to me last year), you have a set of scripts that work fine and in one script you use a numeric index for a SESSION. Once that statement is encountered in the flow of the program, ALL other SESSION variables declared after that don't work anymore. In one sequence of scripts everything worked fine and in a different sequence only some things work. That was maddening and I never knew what it was until now. And, no mention of this problem in the documentation. This should give you a bit more ammunition for your I never use SESSIONs for anything argument. Not really, since I would never name a session variable 1, or 2, or 5318008 - I would always put those in the session in a named array. --- you further stated I would question why you would want to do such a thing. You have never moved data between arrays?!? Come on, I'm sure you have done it before. It's an old habit I have filling arrays -- I never had any problems using numbers before. This works: for ($i; $i10; $i++) { $things[$i] = $other_things[$i]; } I was looking at SESSION the same way -- after all it IS called an array. Let me play the age-card -- in every language I've programmed in for the last 43 years an array can have numeric indexes -- except php's SESSION. I wish I understood the reason why it's like this but I've never looked into the session extension in that level of detail, but I doubt such a limitation would exist if there was not a very good reason for it. But again, I don't see how this is relevant. It's natural to me to see the session array as a filing cabinet. At the top level you would have files with names that indicate what they are. Within each file it may be further divided into numbered sections. Given that I can't see into the future, even if I currently only have one set of data (file) to store in the session (the filing cabinet) I wouldn't just chuck the bits of paper from the file into the filing cabinet. I'd leave them in the file such that when I need to add a new file I don't need to gather up all the other bit of paper into a single file to get it organised again. Ok, that didn't quite make it as clear as I wanted it to but I hope it illustrates the point I'm trying to make. The root level of the session array (IMHO) should contain descriptive keys, and I've never been in a situation where 5318008 is descriptive and gives context to the data unless you turn it upside down! -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
On Sat, Aug 16, 2008 at 10:06 AM, Stut [EMAIL PROTECTED] wrote: I wish I understood the reason why it's like this but I've never looked into the session extension in that level of detail, but I doubt such a limitation would exist if there was not a very good reason for it. But again, I don't see how this is relevant. It's natural to me to see the session array as a filing cabinet. At the top level you would have files with names that indicate what they are. Within each file it may be further divided into numbered sections. Given that I can't see into the future, even if I currently only have one set of data (file) to store in the session (the filing cabinet) I wouldn't just chuck the bits of paper from the file into the filing cabinet. I'd leave them in the file such that when I need to add a new file I don't need to gather up all the other bit of paper into a single file to get it organised again. Ok, that didn't quite make it as clear as I wanted it to but I hope it illustrates the point I'm trying to make. The root level of the session array (IMHO) should contain descriptive keys, and I've never been in a situation where 5318008 is descriptive and gives context to the data unless you turn it upside down! -Stut -- http://stut.net/ Just to add on a thought... The session extension is a global variable. We should make sure our applications play nicely with any other piece of code. We do this by prefixing our functions and classes with something to fake namespaces. The same ideas carry over to any other global construct. So at the very least if I am using the session class I will have $_SESSION['appname'] as my base. Same goes for $GLOBALS, etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
I tend to prefer assigning all my session variables to an array, which itself is a member of the $_SESSION array. For example: $_SESSION[] Array ( [myarray] = Array ( [someitem] = x [someitem2] = y [someitem3] = z ) ) Ash www.ashleysheridan.co.uk ---BeginMessage--- On Sat, Aug 16, 2008 at 10:06 AM, Stut [EMAIL PROTECTED] wrote: I wish I understood the reason why it's like this but I've never looked into the session extension in that level of detail, but I doubt such a limitation would exist if there was not a very good reason for it. But again, I don't see how this is relevant. It's natural to me to see the session array as a filing cabinet. At the top level you would have files with names that indicate what they are. Within each file it may be further divided into numbered sections. Given that I can't see into the future, even if I currently only have one set of data (file) to store in the session (the filing cabinet) I wouldn't just chuck the bits of paper from the file into the filing cabinet. I'd leave them in the file such that when I need to add a new file I don't need to gather up all the other bit of paper into a single file to get it organised again. Ok, that didn't quite make it as clear as I wanted it to but I hope it illustrates the point I'm trying to make. The root level of the session array (IMHO) should contain descriptive keys, and I've never been in a situation where 5318008 is descriptive and gives context to the data unless you turn it upside down! -Stut -- http://stut.net/ Just to add on a thought... The session extension is a global variable. We should make sure our applications play nicely with any other piece of code. We do this by prefixing our functions and classes with something to fake namespaces. The same ideas carry over to any other global construct. So at the very least if I am using the session class I will have $_SESSION['appname'] as my base. Same goes for $GLOBALS, etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
At 3:06 PM +0100 8/16/08, Stut wrote: Not really, since I would never name a session variable 1, or 2, or 5318008 - I would always put those in the session in a named array. That's understandable. But, if you came from a background that predated associate arrays, then using numeric indexes would seem more natural. To me arrays come in two types, those with numeric indexes and those with string indexes. I use both. I wish I understood the reason why it's like this but I've never looked into the session extension in that level of detail, but I doubt such a limitation would exist if there was not a very good reason for it. But again, I don't see how this is relevant. I never said it was relevant. I am sure too that whatever the reason was, it made sense at the time and for the problem of the time -- similar to the a1 z discussion of a couple of years back. It's natural to me to see the session array as a filing cabinet. At the top level you would have files with names that indicate what they are. Within each file it may be further divided into numbered sections. Given that I can't see into the future, even if I currently only have one set of data (file) to store in the session (the filing cabinet) I wouldn't just chuck the bits of paper from the file into the filing cabinet. I'd leave them in the file such that when I need to add a new file I don't need to gather up all the other bit of paper into a single file to get it organised again. Ok, that didn't quite make it as clear as I wanted it to but I hope it illustrates the point I'm trying to make. The root level of the session array (IMHO) should contain descriptive keys, and I've never been in a situation where 5318008 is descriptive and gives context to the data unless you turn it upside down! I understand what you are saying -- semantics are important. But if there is a need for temporary place to store values I don't consider it bad form to store them in a numerically indexed array. For example, if a user was going to purchase up to 10 items, I see nothing wrong is using: user_purchase[0] = $item0; ... user_purchase[9] = $item9; And as such, one can easily extract what the user purchased by simply using for(). However, in this case I don't see the gain provided by using: user_purchase['item1'] = $item0; ... user_purchase['item9'] = $item9; But that distinction would be required IF you were using SESSIONs. And that's one of my points -- normal arrays come in two types and the SESSION array don't. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
On 16 Aug 2008, at 17:03, tedd wrote: I understand what you are saying -- semantics are important. But if there is a need for temporary place to store values I don't consider it bad form to store them in a numerically indexed array. For example, if a user was going to purchase up to 10 items, I see nothing wrong is using: user_purchase[0] = $item0; ... user_purchase[9] = $item9; And as such, one can easily extract what the user purchased by simply using for(). However, in this case I don't see the gain provided by using: user_purchase['item1'] = $item0; ... user_purchase['item9'] = $item9; But that distinction would be required IF you were using SESSIONs. And that's one of my points -- normal arrays come in two types and the SESSION array don't. I think you're missing the core of my point. My point only refers to the root level of the $_SESSION array. I have no problem with using numerically-indexed arrays elsewhere - I come from a C background so it's where I started too and frequently use them. However, in the example above you would not use... $_SESSION[0] = $item0; ... $_SESSION[9] = $item9; Instead I assert you would have... $_SESSION['user_purchase'][0] = $item0; ... $_SESSION['user_purchase'][9] = $item9; which is perfectly valid. I'll try to re-word my basic point... I personally consider it bad to even want to use numeric indexes at the root level of the $_SESSION array because it creates data with no context in a globally accessible location. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
Hi Tedd, tedd schrieb: At 2:45 PM +0200 8/16/08, Sabine Richter wrote: Yes, our mails overlaped each other (Do you say that in english? My english is not the best.) Sabine: Your English is fine -- much better than my de for certain. Thanks :-) By the way: I tried your initial code and I had no problem with the variable declared after the numeric ones. (your $_SESSION['test']). I tried on a Version 5.2.5 an Win XP. That's interesting. Let's make sure we're talking about the same thing here. This is the demo: http://www.webbytedd.com/b2/session-test1/index.php In my browser Step 1 shows: SESSION[20] = good morning SESSION[test2] = good night In Step 2: Neither are there. Is that what you see? I tried the script from your first example on http://www.webbytedd.com/b2/session-test/index1.php I just deleted the header and footer includes and set the error reporting to E_ALL. That's what I get: index.php: f411abf8cb6cb7e0f2d091251c1906dd Step 1 -- SESSIONs Recorded 1 = 1 2 = 2 3 = 3 4 = 4 5 = 5 6 = 6 7 = 7 8 = 8 9 = 9 10 = 10 hello Code: ?php // Session problem tedd sperling, php liste 15.08.2008 ini_set('error_reporting', E_ALL ); if (session_id() == ) { session_start(); } echo(session_id()); for ($i = 1; $i = 10; $i++) { $_SESSION[$i] = $i; } $_SESSION['test'] = 'hello'; ? h1Step 1 -- SESSIONs Recorded/h1 ?php for ($i = 1; $i = 10; $i++) { echo($i = $_SESSION[$i] br/); } echo($_SESSION['test']); ? br/ br/ form action=index1.php method=post input type=submit value=Proceed to Step 2 /form hr/ Code: br/ br/ ?php highlight_file (index.php); ? Notice: Unknown: Skipping numeric key 1. in Unknown on line 0 Notice: Unknown: Skipping numeric key 2. in Unknown on line 0 Notice: Unknown: Skipping numeric key 3. in Unknown on line 0 Notice: Unknown: Skipping numeric key 4. in Unknown on line 0 Notice: Unknown: Skipping numeric key 5. in Unknown on line 0 Notice: Unknown: Skipping numeric key 6. in Unknown on line 0 Notice: Unknown: Skipping numeric key 7. in Unknown on line 0 Notice: Unknown: Skipping numeric key 8. in Unknown on line 0 Notice: Unknown: Skipping numeric key 9. in Unknown on line 0 Notice: Unknown: Skipping numeric key 10. in Unknown on line 0 index1.php: f411abf8cb6cb7e0f2d091251c1906dd Step 2 -- Results of SESSIONs passed Notice: Undefined offset: 1 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 1 = Notice: Undefined offset: 2 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 2 = Notice: Undefined offset: 3 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 3 = Notice: Undefined offset: 4 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 4 = Notice: Undefined offset: 5 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 5 = Notice: Undefined offset: 6 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 6 = Notice: Undefined offset: 7 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 7 = Notice: Undefined offset: 8 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 8 = Notice: Undefined offset: 9 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 9 = Notice: Undefined offset: 10 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 10 = hello Code: ?php // Session problem tedd sperling, php liste 15.08.2008 ini_set('error_reporting', E_ALL ); if (session_id() == ) { session_start(); } echo(session_id()); ? h1Step 2 -- Results of SESSIONs passed/h1 ?php for ($i = 1; $i = 10; $i++) { echo($i = $_SESSION[$i] br/); } echo($_SESSION['test']); ? br/ br/ form action=index.php method=post input type=submit value=Go Back to Step 1 /form hr/ Code: br/ br/ ?php highlight_file (index1.php); ? You see, I get the content of $_SESSION['test'] in index1.php. It's the same as in your second example, isn't it? I would try your second example too, but you highlighted the code of index.php in index1.php too. So I can't. Cheers Sabine Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
At 5:15 PM +0100 8/16/08, Stut wrote: Instead I assert you would have... $_SESSION['user_purchase'][0] = $item0; ... $_SESSION['user_purchase'][9] = $item9; which is perfectly valid. I'll try to re-word my basic point... I personally consider it bad to even want to use numeric indexes at the root level of the $_SESSION array because it creates data with no context in a globally accessible location. Ahhh, I see with what you're saying -- that's a good point. For my temp variables, I should have used some like: $_SESSION['tedd_temps'][0] = $item0; ... $_SESSION['tedd_temps'][9] = $item9; That would have fit much better if I had been programming in a group. Thanks for taking the time to explain that. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
Sabine: I understand the problem now. But to get to my basic question to you, namely using this link: http://www.webbytedd.com/b2/session-test1/index.php -- does SESSION[20] and SESSION[test2] show anything in the second step (Step 2) or are the results blank? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
tedd schrieb: Sabine: I understand the problem now. But to get to my basic question to you, namely using this link: http://www.webbytedd.com/b2/session-test1/index.php -- does SESSION[20] and SESSION[test2] show anything in the second step (Step 2) or are the results blank? Oh, ok, when I just call your URL: they are both blank! Cheers, Sabine Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
On Fri, Aug 15, 2008 at 1:09 PM, tedd [EMAIL PROTECTED] wrote: Hi gang: Arrggg -- what the heck is going on? I can't get anything to pass via SESSION -- what's wrong? Here's the example -- (all the code is there): I populate the $_SESSIONs here. http://www.webbytedd.com/b2/session-test/index.php If you click Proceed to Step 2, you'll see that nothing is passed. Now, where did I go wrong? Cheers, tedd PS: I've tried this on two different servers and get the same results. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What's in your header.php? -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life.
Re: [PHP] SESSION problem
On Aug 15, 2008, at 12:16 PM, Dan Joseph wrote: On Fri, Aug 15, 2008 at 1:09 PM, tedd [EMAIL PROTECTED] wrote: Hi gang: Arrggg -- what the heck is going on? I can't get anything to pass via SESSION -- what's wrong? Here's the example -- (all the code is there): I populate the $_SESSIONs here. http://www.webbytedd.com/b2/session-test/index.php If you click Proceed to Step 2, you'll see that nothing is passed. Now, where did I go wrong? Cheers, tedd PS: I've tried this on two different servers and get the same results. What's in your header.php? It probably won't make a difference, but you may try: ?php for ($i = 1; $i = 10; $i++) { echo($i = {$_SESSION[$i]} br/); } ? Throw the $_SESSION into {}. ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SESSION problem
-Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2008 12:10 PM To: php-general@lists.php.net Subject: [PHP] SESSION problem Hi gang: Arrggg -- what the heck is going on? I can't get anything to pass via SESSION -- what's wrong? Here's the example -- (all the code is there): I populate the $_SESSIONs here. http://www.webbytedd.com/b2/session-test/index.php If you click Proceed to Step 2, you'll see that nothing is passed. Now, where did I go wrong? Cheers, tedd PS: I've tried this on two different servers and get the same results. Have you tried: echo SID; ...? I'm wondering if you're going to get different values on the two pages. What that means beyond two different sessions is beyond me, but it's a start. Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SESSION problem
At 1:47 PM -0500 8/15/08, Boyd, Todd M. wrote: Have you tried: echo SID; ...? I'm wondering if you're going to get different values on the two pages. What that means beyond two different sessions is beyond me, but it's a start. Todd Boyd Web Programmer Todd: I added code to show the SID and it's the same, but still nothing happens. http://www.webbytedd.com/b2/session-test/index.php I know what the problem is, but don't know how to fix it. If you will look at the code, I am using a variable within the SESSION declaration: $_SESSION[$i] = $i; If I comment that out, the $_SESSION['test'] will be passed. Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
Tedd, I think according to PHP manual. Session_start() must be the first line in the code. Dont worry it will remember your session until you close the browser and also it wont duplicate it. Thanks On Fri, Aug 15, 2008 at 4:39 PM, tedd [EMAIL PROTECTED] wrote: At 1:47 PM -0500 8/15/08, Boyd, Todd M. wrote: Have you tried: echo SID; ...? I'm wondering if you're going to get different values on the two pages. What that means beyond two different sessions is beyond me, but it's a start. Todd Boyd Web Programmer Todd: I added code to show the SID and it's the same, but still nothing happens. http://www.webbytedd.com/b2/session-test/index.php I know what the problem is, but don't know how to fix it. If you will look at the code, I am using a variable within the SESSION declaration: $_SESSION[$i] = $i; If I comment that out, the $_SESSION['test'] will be passed. Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
On Nov 21, 2007 11:08 AM, Mathieu Dumoulin [EMAIL PROTECTED] wrote: I got a strange problem here, here are the setup details first as this seems to be a server problem more than a php problem but it is still related to php configuration: Server: Win2003 (latest) WebServer: IIS6 (latest) PHP: php5.2.2.1 MySQL: mysql.5 Sites installed in server that may have influence: www.palliscience.com dev.palliscience.com maj.palliscience.com dev2.palliscience.com (All sites are installed using php5_ISAPI.dll) Problem: When i try to start a session in maj.palliscience.com (Same code as everywhere else except the content may differ), the server hangs. I tried for two days to find and make sure where this server hang was coming from and eventually came to the solid conclusion that my server hang on session_start. I tried to add different commands such as session_write_close at end of my scripts and checked that my sessions where not already open by using session_id. The only way i was able to make my sessions work in maj.palliscience.comis using the CGI version of PHP, but hell this is causing me problems i never thought it would. I'm having problems with headers, and also the $_SERVER variable is deadly different. So my question is simple, what could cause this problem. Windoze and IIS. =/ Could it be a clash in the filenames for the session files? Yes, AFAIK, the session names will clash. Meaning, for each DNS (subdomain, whatever it is), use a different prefix to avoid clashes: $_SESSION['www'][...] $_SESSION['dev'][...] $_SESSION['maj']...] etc. Obviously if some are in production, this is not a trivial change. I tried reading a bit the php.ini and saw there is a way to split the session files in different folders but i don't have the expertise nor the famous script the php.ini is talking about in the session section to fix or alter this info correctly. (I can't start tweaking this, there are other sites on the machine that are in production mode so i need a final configuration that will work on the first try) Keep in mind: 1) I got 3 other sites that sport the same code, only slightly different content 2) All the sessions in the other sites work marvelously in ISAPI 3) Only maj is affected, i tried copying the code to dev2.palliscience.com , problem doesn't show. 4) I can definitely say my sessions are problematic, i comment out any session_start, and the problem nevers shows This is a stab in the dark, but maybe the problem is not with session_start. Maybe session_start uses/calls something else which has a negative impact on your system. So you may be addressing the issue, but from the wrong angle?? Thanks Mathieu Dumoulin Well, I gave you a lot of useless information, but hopefully it sparks a fire! =D Good Luck. ~Philip
RE: [PHP] Session problem
-Original Message- From: Philip Thompson [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 21, 2007 4:43 PM To: php-general@lists.php.net Subject: Re: [PHP] Session problem On Nov 21, 2007 11:08 AM, Mathieu Dumoulin [EMAIL PROTECTED] wrote: I got a strange problem here, here are the setup details first as this seems to be a server problem more than a php problem but it is still related to php configuration: Server: Win2003 (latest) WebServer: IIS6 (latest) PHP: php5.2.2.1 MySQL: mysql.5 Sites installed in server that may have influence: www.palliscience.com dev.palliscience.com maj.palliscience.com dev2.palliscience.com (All sites are installed using php5_ISAPI.dll) Problem: When i try to start a session in maj.palliscience.com (Same code as everywhere else except the content may differ), the server hangs. I tried for two days to find and make sure where this server hang was coming from and eventually came to the solid conclusion that my server hang on session_start. I tried to add different commands such as session_write_close at end of my scripts and checked that my sessions where not already open by using session_id. The only way i was able to make my sessions work in maj.palliscience.comis using the CGI version of PHP, but hell this is causing me problems i never thought it would. I'm having problems with headers, and also the $_SERVER variable is deadly different. So my question is simple, what could cause this problem. Windoze and IIS. =/ Could it be a clash in the filenames for the session files? Yes, AFAIK, the session names will clash. Meaning, for each DNS (subdomain, whatever it is), use a different prefix to avoid clashes: $_SESSION['www'][...] $_SESSION['dev'][...] $_SESSION['maj']...] etc. Obviously if some are in production, this is not a trivial change. I tried reading a bit the php.ini and saw there is a way to split the session files in different folders but i don't have the expertise nor the famous script the php.ini is talking about in the session section to fix or alter this info correctly. (I can't start tweaking this, there are other sites on the machine that are in production mode so i need a final configuration that will work on the first try) Keep in mind: 1) I got 3 other sites that sport the same code, only slightly different content 2) All the sessions in the other sites work marvelously in ISAPI 3) Only maj is affected, i tried copying the code to dev2.palliscience.com , problem doesn't show. 4) I can definitely say my sessions are problematic, i comment out any session_start, and the problem nevers shows This is a stab in the dark, but maybe the problem is not with session_start. Maybe session_start uses/calls something else which has a negative impact on your system. So you may be addressing the issue, but from the wrong angle?? Thanks Mathieu Dumoulin Well, I gave you a lot of useless information, but hopefully it sparks a fire! =D Good Luck. ~Philip I don't think there's a name clash in session file names... session identification is based on a browser cookie if I remember well PHPSESSIONID, and so are file names which (again, if my memory is right) are called sess_session_id where session_id is the aforementioned cookie. Cookies are different for different (sub)domains... so, the browser won't send the session cookie for www.domain.com to dev.domain.com... meaning both subdomains should get different session ids and session files (which cannot clash because the session id is generated randomly using an MD5 hash, right?). I would say the problem is at some point in the IIS-PHP communication. Maybe the browser is sending the session ID to the server, the server gets the session id, and when you use session_start it tries to grab the file which is locked (for some extrange and unknown windows reason as usual) and then it hangs waiting for the file to be available. I don't know if this will be of any help for you, but I'd locate the session files directory (the location can be found in PHP.INI) and delete every file in there, and if possible restart the webserver. Also, there's a debugging tool in the IIS 6.0 resource kit that can be used to log and/or point out problems in the IIS worker processes (can't remember its name, I had to deal with that about two years ago). That will at least give you some use(ful|less) information about which process is faulting, what's the exception and which is the code causing the fault. If there's any fault of course... if it's only a deadlock, it might provide no useful information, because the IIS process would simply be waiting for the session file to be available for read(write). Ok... this was just another bit of probably useless information... but someone will help us out, I know. Rob -- PHP General Mailing List
RE: [PHP] Session problem
By the way... I remember there were to ways of installing PHP over IIS. One was adding it for ALL websites and the other way was adding it on a site by site basis. I'd recommend doing the second method. Notice that this has nothing to do with ISAPI vs CGI, it is just an option in IIS settings (again, I've not seen a Windows 2003 Server since about two years ago, so I don't remember where or how this was accomplished). Rob (excuse me for top posting, but this is just a side note) -Original Message- From: Andrés Robinet [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 21, 2007 5:51 PM To: php-general@lists.php.net Subject: RE: [PHP] Session problem -Original Message- From: Philip Thompson [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 21, 2007 4:43 PM To: php-general@lists.php.net Subject: Re: [PHP] Session problem On Nov 21, 2007 11:08 AM, Mathieu Dumoulin [EMAIL PROTECTED] cdgi.com wrote: I got a strange problem here, here are the setup details first as this seems to be a server problem more than a php problem but it is still related to php configuration: Server: Win2003 (latest) WebServer: IIS6 (latest) PHP: php5.2.2.1 MySQL: mysql.5 Sites installed in server that may have influence: www.palliscience.com dev.palliscience.com maj.palliscience.com dev2.palliscience.com (All sites are installed using php5_ISAPI.dll) Problem: When i try to start a session in maj.palliscience.com (Same code as everywhere else except the content may differ), the server hangs. I tried for two days to find and make sure where this server hang was coming from and eventually came to the solid conclusion that my server hang on session_start. I tried to add different commands such as session_write_close at end of my scripts and checked that my sessions where not already open by using session_id. The only way i was able to make my sessions work in maj.palliscience.comis using the CGI version of PHP, but hell this is causing me problems i never thought it would. I'm having problems with headers, and also the $_SERVER variable is deadly different. So my question is simple, what could cause this problem. Windoze and IIS. =/ Could it be a clash in the filenames for the session files? Yes, AFAIK, the session names will clash. Meaning, for each DNS (subdomain, whatever it is), use a different prefix to avoid clashes: $_SESSION['www'][...] $_SESSION['dev'][...] $_SESSION['maj']...] etc. Obviously if some are in production, this is not a trivial change. I tried reading a bit the php.ini and saw there is a way to split the session files in different folders but i don't have the expertise nor the famous script the php.ini is talking about in the session section to fix or alter this info correctly. (I can't start tweaking this, there are other sites on the machine that are in production mode so i need a final configuration that will work on the first try) Keep in mind: 1) I got 3 other sites that sport the same code, only slightly different content 2) All the sessions in the other sites work marvelously in ISAPI 3) Only maj is affected, i tried copying the code to dev2.palliscience.com , problem doesn't show. 4) I can definitely say my sessions are problematic, i comment out any session_start, and the problem nevers shows This is a stab in the dark, but maybe the problem is not with session_start. Maybe session_start uses/calls something else which has a negative impact on your system. So you may be addressing the issue, but from the wrong angle?? Thanks Mathieu Dumoulin Well, I gave you a lot of useless information, but hopefully it sparks a fire! =D Good Luck. ~Philip I don't think there's a name clash in session file names... session identification is based on a browser cookie if I remember well PHPSESSIONID, and so are file names which (again, if my memory is right) are called sess_session_id where session_id is the aforementioned cookie. Cookies are different for different (sub)domains... so, the browser won't send the session cookie for www.domain.com to dev.domain.com... meaning both subdomains should get different session ids and session files (which cannot clash because the session id is generated randomly using an MD5 hash, right?). I would say the problem is at some point in the IIS-PHP communication. Maybe the browser is sending the session ID to the server, the server gets the session id, and when you use session_start it tries to grab the file which is locked (for some extrange and unknown windows reason as usual) and then it hangs waiting for the file to be available. I don't know if this will be of any help for you, but I'd locate the session files
Re: [PHP] Session problem
Does no one have some solution or suggestion? Dušan On 9/29/07, Dušan Novaković [EMAIL PROTECTED] wrote: Hm.. I don't know that. I have also another application on the same server, and I haven't encountered problems of the same kind. I don't know whether these problems don't happend at all on this other application, or I just haven't come across one. :-( Dušan On 9/28/07, Jim Lucas [EMAIL PROTECTED] wrote: Dušan Novaković wrote: Hi, I have two problems with sessions. Firstly, even though session limit is set on default value on server, which is about 5 hours, if I don't take any action for about 15 mins I am thrown out and I have to log in again. Are there any addition functions which I can use in order to explicitly specify session lifetime? Secondly, after a certain period of time, while I am logged in, page just freezes and it indicates that it is trying to load. Page stays frozen all the time. At that moment, the only solution is to clear private data in the browser. After that, I am logged out and I can regulary log in and procede to work normally. It doesn't happend evry time I log in, but once in while. I have only used functions such as session_start() and session_destroy. Thanks for your help, Dušan - - made by Dusan sounds like a problem with the hosting provider. Is this a single server that you have your web site on, or is it a farm of servers? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- made by Dusan -- made by Dusan
Re: [PHP] Session problem
Dušan Novaković wrote: Does no one have some solution or suggestion? Dušan On 9/29/07, Dušan Novaković [EMAIL PROTECTED] wrote: Hm.. I don't know that. I have also another application on the same server, and I haven't encountered problems of the same kind. I don't know whether these problems don't happend at all on this other application, or I just haven't come across one. :-( Dušan On 9/28/07, Jim Lucas [EMAIL PROTECTED] wrote: Dušan Novaković wrote: Hi, I have two problems with sessions. Firstly, even though session limit is set on default value on server, which is about 5 hours, if I don't take any action for about 15 mins I am thrown out and I have to log in again. Are there any addition functions which I can use in order to explicitly specify session lifetime? Secondly, after a certain period of time, while I am logged in, page just freezes and it indicates that it is trying to load. Page stays frozen all the time. At that moment, the only solution is to clear private data in the browser. After that, I am logged out and I can regulary log in and procede to work normally. It doesn't happend evry time I log in, but once in while. I have only used functions such as session_start() and session_destroy. Thanks for your help, Dušan - - made by Dusan sounds like a problem with the hosting provider. Is this a single server that you have your web site on, or is it a farm of servers? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- made by Dusan I would have the host then double check the config. Make sure the location where the session files are being written to is writable by the php user. Have them compare the two configs between the different sites. See if anything besides the document root is different. Or, upgrade to a dedicated host and run the web server your self. -- Jim Lucas Perseverance is not a long race; it is many short races one after the other Walter Elliot Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
Dušan Novaković wrote: Hi, I have two problems with sessions. Firstly, even though session limit is set on default value on server, which is about 5 hours, if I don't take any action for about 15 mins I am thrown out and I have to log in again. Are there any addition functions which I can use in order to explicitly specify session lifetime? Secondly, after a certain period of time, while I am logged in, page just freezes and it indicates that it is trying to load. Page stays frozen all the time. At that moment, the only solution is to clear private data in the browser. After that, I am logged out and I can regulary log in and procede to work normally. It doesn't happend evry time I log in, but once in while. I have only used functions such as session_start() and session_destroy. Thanks for your help, Dušan - - made by Dusan sounds like a problem with the hosting provider. Is this a single server that you have your web site on, or is it a farm of servers? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
Brad Bonkoski wrote: How do you move from one page to the other? You have to pass the session along, I believe.. Something like: $s = SID; // session contant page2.php?$s You only need to pass the session identifier in the query string if you aren't using cookies. By default, sessions will be handled with cookies, so they work transparently. I suspect, as others have suggested, that there is a path/permission problem and the session data is not getting saved. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Problem
Does your system have permission to write to the temp directory? Put on error_reporting(E_ALL) and see if it throws an error. -Original Message- From: LoneWolf [mailto:[EMAIL PROTECTED] Sent: Thursday, February 15, 2007 2:35 PM To: php-general@lists.php.net Subject: [PHP] Session Problem I am having a problem where it appears that the session is not being saved properly. While on a page, I can start a session and set variables to it. however, when I go to the next page.. the session variables appear to have been cleared out. first page: session_start(); $_SESSION[user_level] = test; second page: session_start(); echo $_SESSION[user_level] ; We just installed php on the 2003 server. Is there maybe a problem with the php.ini file that I need to fix? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
LoneWolf wrote: I am having a problem where it appears that the session is not being saved properly. While on a page, I can start a session and set variables to it. however, when I go to the next page.. the session variables appear to have been cleared out. first page: session_start(); $_SESSION[user_level] = test; How do you move from one page to the other? You have to pass the session along, I believe.. Something like: $s = SID; // session contant page2.php?$s second page: session_start(); echo $_SESSION[user_level] ; We just installed php on the 2003 server. Is there maybe a problem with the php.ini file that I need to fix? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Problem
-Original Message- From: LoneWolf [mailto:[EMAIL PROTECTED] Sent: Thursday, February 15, 2007 4:35 PM To: php-general@lists.php.net Subject: [PHP] Session Problem I am having a problem where it appears that the session is not being saved properly. While on a page, I can start a session and set variables to it. however, when I go to the next page.. the session variables appear to have been cleared out. Is there anything unusual about your setup that you failed to mention? (e.g. using frameset etc.) A few things to check: - Make sure cookies (at least session cookies) are enabled in your browser. - Try browsing the site from another computer. - Make sure session_start() is being called before any HTML output (including blank lines before the first ?php tag) -Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session-problem? Simple counter won't work
Sabine wrote: Hello to all, I'm working on a server where even a simple counter-script won't work. session_start(); if (isset($HTTP_SESSION_VARS['counter'])) { $HTTP_SESSION_VARS['counter']++; } else { $HTTP_SESSION_VARS['counter']=1; } On every refresh the counter is set to 1. I take it this is not inside a function? have you tried using var_dump() to output $HTTP_SESSION_VARS? you may be stuck with doing things the old session_register() way rather than using $HTTP_SESSION_VARS (or preferably $_SESSION - if you had a version of php at your disposal that had that.) I dont' know, where to search for the reasons. The server is a normal service providers server. My customers site is using sessions and they are working on his site. I would suggest that you go thru his code line by line to figure out how it works. also check out this page: http://php.net/manual/en/function.session-set-cookie-params.php given that you want your own session on a specific subpath you will have to do some more owkr than just start the session. My script lays in a subdirectory of my costumers site, protected with a .htaccess.: The PHP-Version is 4.0.6. which idiot is setting 4.0.6 as a requirement - its old, has lots of bugs that have been fixed in more recent versions and is full _known_ security issues (which have also been fixed) ... upgrade is the sane thing to do. if there is one other person on this list using 4.0.6 you'll be lucky. all this means that your going to have a hard time getting things done - bottom line this costs your customer more (you are passing on the cost right?) The values for the session-parameters are, as far as I see, standard: session.save_handler: files session.save_path: /tmp Register-globals is set to on. Has anybody an idea where the problem lays? Is it possible that I don' have the right to write into the /tmp-directory? possible but unlikely, given that the main site works. try writing a file to /tmp. It would be very nice of you to give me some tips. I don't want to ask my customer silly questions. your customer is requiring 4.0.6 - nothing you can ask could be sillier than that ;-) (other than maybe asking to downgrade to php3) Thanks in advance Sabine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session problem
Hi -Original Message- From: Rosen [mailto:[EMAIL PROTECTED] Sent: Thursday, March 31, 2005 11:31 AM To: php-general@lists.php.net Subject: [PHP] Session problem Hi, I have this code : page1.php: ? $nfo[fu]=12; session_start(); session_register(nfo); For good programmingskill always start with session_start() (one day You might print something before) $sn=session_name(); $nn=session_id() ; $web=page2.php?lang=en; $web.=$sn=$nn; header(Location: $web); ? === page2.php: ? session_start(); global $nfo; $uss=$nfo[fu]; echo $uss; HERE $uss is empty! Yeah, cause that´s _not_ what the manual says: http://dk.php.net/manual/en/ref.session.php It should be $_SESSION['nfo']['fu'] = 12; -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
Kevin Javia wrote: Hi there, I have got PHP 5 installed on IIS6 with 'register_globals = on'. consider switching it off. your application will be impossible to install on any other server if you keep working on it with register global s on. When run my page with session variable at top of the page ? $_SESSION['_user'] == .. ? Is your syntax correct if you want to set a value for this you need to use '=' and not '==' I got notice like Notice: Undefined index: _user in E:\Projects\. this is just a warning, you can disable it or write it to the log file instead of the browser by editing your php.ini What can be the reason and what is the solution? _user variable is not registered before. The fact that it's not registered and that you are using it in a comparision operation is what's caused the engine to give you a warning. Thanks a ton for reading this far. Kevin. -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
Make sure you are doing a session_start first. On Tue, 5 Oct 2004 19:00:57 +0530, Kevin Javia [EMAIL PROTECTED] wrote: Hi there, I have got PHP 5 installed on IIS6 with 'register_globals = on'. When run my page with session variable at top of the page ? $_SESSION['_user'] == .. ? I got notice like Notice: Undefined index: _user in E:\Projects\. What can be the reason and what is the solution? _user variable is not registered before. Thanks a ton for reading this far. Kevin. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem PHP version 4.3.8
Hi James, Well for what it's worth: Your code in Test1 sets the paraemters - if(!$_SESSION['start_time']){ echo(\n Session ResetBR); $_SESSION['start_time'] = time(); yet when Test2 loads, you haven't called $_SESSION[''start_time'} nor, for that matter, have you 'saved' it using session_write_close(); Therefore when the Test2 loads, time is not set, so when it returns to Test1 and hits the above condition, it will write a new time, and hence a new session. I presume two things; 1. that you have ?php session_start(); ? as opener lines on each page and 2. that register_globals=off. The last thing caused all sorts of grief for me last week - messes up sessions if 'on' Hth, Andre On Friday 13 August 2004 10:37 am, James E Hicks III wrote: OK, so it wasn't the nut behind the wheel after all. I am still having problems with sessions after upgrading to PHP 4.3.8. The test code below works as expected on server equipped with PHP 4.3.6 and keeps the session start time the same no matter what link you click on. However with version 4.3.8 when you click on the last link on the page it will start a new session and the session start time will be updated. What can I change to fix this? All the session related php.ini settings are the same on both servers and I will repost that information here. Both servers are running the same version of Apache, Server version: Apache/1.3.27 (Unix) (Gentoo/Linux). ## Session settings in php.ini [Session] session.save_handler = files session.save_path = /tmp session.use_cookies = 1 ; session.use_only_cookies = 1 session.name = PHPSESSID session.auto_start = 1 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.serialize_handler = php session.gc_probability = 1 session.gc_divisor = 100 session.gc_maxlifetime = 1440 session.bug_compat_42 = 1 session.bug_compat_warn = 1 session.referer_check = session.entropy_length = 0 session.entropy_file = ;session.entropy_length = 16 ;session.entropy_file = /dev/urandom session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 url_rewriter.tags = a=href,area=href,frame=src,input=src,form=,fieldset= And here is the example code that I am having trouble with. SESSION_TEST1.php ?php echo(\n HTMLHEADTITLESESSION TEST/TITLE); echo(\n SCRIPT LANGUAGE=\JavaScript\); echo(\n !-- Begin ); echo(\n function popUpBI(URL) { ); echo(\n day = new Date(); ); echo(\n id = day.getTime(); ); echo(\n eval(\page\ + id + \ = window.open(URL, '\ + id + \', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,widt h=400,height=400'); \); ); echo(\n } ); echo(\n // End -- ); echo(\n /script); echo(\n /HEADBODY); if(!$_SESSION['start_time']){ echo(\n Session ResetBR); $_SESSION['start_time'] = time(); } echo(\n BRSession Start Time -.date(M/d/Y h:i:s, $_SESSION['start_time'])); echo(\n form action=\.$_SERVER['PHP_SELF'].\ method=\POST\); echo(\n BRinput type=\submit\ name=\submit\ value=\THIS WORKS\); echo(\n /form); echo(\n BRA HREF=\SESSION_TEST1.php\THIS ALSO WORKS/A); echo(\n BRBRA HREF=\javascript:popUpBI('SESSION_TEST2.php')\THIS STARTS NEW SESSION/A); echo(\n /BODY/HTML); ? SESSION_TEST2.php ?php echo(\n HTMLHEADTITLESESSION TEST 2/TITLE/HEADBODY); echo(\n Now there is new session and the other window will update with new timeBR); echo(\n BRa href=\javascript:window.close();\fontClose This Window/font/a); echo(\n /BODY/HTML); ? Help James Hicks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem PHP version 4.3.8
On Friday 13 August 2004 11:14 am, Andre Dubuc wrote: Hi James, Well for what it's worth: Your code in Test1 sets the paraemters - if(!$_SESSION['start_time']){ echo(\n Session ResetBR); $_SESSION['start_time'] = time(); yet when Test2 loads, you haven't called $_SESSION[''start_time'} nor, for that matter, have you 'saved' it using session_write_close(); From the Manual: Session data is usually stored after your script terminated without the need to call session_write_close(), Therefore when the Test2 loads, time is not set, so when it returns to Time is set. Test1 and hits the above condition, it will write a new time, and hence a new session. It should never hit the if condition after the first load of the page. I presume two things; 1. that you have ?php session_start(); ? as opener lines on each page and 2. that register_globals=off. In my php.ini I have session.auto_start = 1, so that I do not need session_start(). And register_globals is set to off. The last thing caused all sorts of grief for me last week - messes up sessions if 'on' Been there done that! Thanks for trying to help! James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem PHP version 4.3.8
On Friday 13 August 2004 11:19 am, you wrote: On Friday 13 August 2004 11:14 am, Andre Dubuc wrote: Hi James, [snip] .for thatt matter, have you 'saved' it using session_write_close(); From the Manual: Session data is usually stored after your script terminated without the need to call session_write_close(), [snip] Well, for my money James, that's where your problem lies. Notice the usually in the Manual quote. In my experience, it never saves unless I write to it. But, with your config, with session.auto_start=1, if I read that correctly, it will do nothing other than start the session automatically, but not save a change to a session variable. Hence, it reloads with a 'not-set' condition in that code. And by the way, it is hitting that if condition - hence your reset session. Just my $2 worth (inflation, you know :) Andre Time is set. Test1 and hits the above condition, it will write a new time, and hence a new session. It should never hit the if condition after the first load of the page. I presume two things; 1. that you have ?php session_start(); ? as opener lines on each page and 2. that register_globals=off. In my php.ini I have session.auto_start = 1, so that I do not need session_start(). And register_globals is set to off. The last thing caused all sorts of grief for me last week - messes up sessions if 'on' Been there done that! Thanks for trying to help! James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem PHP version 4.3.8
Hi Andre, hi James, please see below Andre Dubuc [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Friday 13 August 2004 11:19 am, you wrote: On Friday 13 August 2004 11:14 am, Andre Dubuc wrote: Hi James, [snip] .for thatt matter, have you 'saved' it using session_write_close(); From the Manual: Session data is usually stored after your script terminated without the need to call session_write_close(), [snip] Well, for my money James, that's where your problem lies. Notice the usually in the Manual quote. In my experience, it never saves unless I write to it. Then something is wrong with your server. You DO NOT need to explicitly call session_write_close(). But, with your config, with session.auto_start=1, if I read that correctly, it will do nothing other than start the session automatically, but not save a change to a session variable. Hence, it reloads with a 'not-set' condition in that code. And by the way, it is hitting that if condition - hence your reset session. James, have you tried with manually calling session_start() and setting auto_start = 0? If not, please try this. Haven't followed your previous thread so please forgive me if I'm asking something you already wrote. Are you using cookies? If so, have you tried without them by appending the session id manually to the links? Try these settings: session.auto_start= 0 session.use_cookies = 0 session.use_trans_sid = 0 Put session_start() at the top of ALL your pages and write your links this way: a href=page2.php??php echo SID; ?to page 2 /a Hope it helps, Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem PHP version 4.3.8
On Friday 13 August 2004 01:14 pm, Torsten Roehr wrote: James, have you tried with manually calling session_start() and setting auto_start = 0? If not, please try this. Haven't followed your previous thread so please forgive me if I'm asking something you already wrote. Are you using cookies? YES These are my current cookie related php.ini settings. session.use_cookies = 1 ; session.use_only_cookies defaults to 0 ; session.use_only_cookies = 1 If so, have you tried without them by appending the session id manually to the links? I tried that without turning cookies off and appending the SID to the offending anchor tag (the one with javascript). Nothing I tried worked with current php.ini settings. I tried like this: echo(\n BRBRA HREF=\javascript:popUpBI('SESSION_TEST2.php?.SID.')\THIS STARTS NEW SESSION/A); Which gave me this anchor tag: A HREF=javascript:popUpBI('SESSION_TEST2.php?')THIS STARTS NEW SESSION/A And like this: echo (a href=\javascript:popUpBI('SESSION_TEST2.php?PHPSESSID=. $_REQUEST['PHPSESSID'].')\THIS STARTS NEW SESSION/A); Which gave me this anchor tag: A HREF=javascript:popUpBI('SESSION_TEST2.php?PHPSESSID=fae0cffb9f6c307e38aef7d2310e1d69')THIS STARTS NEW SESSION/A Try these settings: session.auto_start = 0 session.use_cookies = 0 session.use_trans_sid = 0 Put session_start() at the top of ALL your pages and write your links this way: a href=page2.php??php echo SID; ?to page 2 /a I tried with php.ini settings like you suggested and it didn't work at all. Whatever you clicked on started a new session. Then I turned session.use_trans_sid = 1 with auto_start and use_cookies still turned off and my example code started working!!! My problem is that all my other real world apps do not work with php.ini settings like that. :( So it seems that the cookie part of sessions is broken somehow and my earlier idea of adding something to url_rewrite wouldn't help even if I could figure out what to add to it. Anyone have any other ideas. Can I upgrade to something higher than 4.3.8? Would that mean upgrading to 5.x? James Hicks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
Hello Carlos, Wednesday, March 24, 2004, 2:52:16 PM, you wrote: cc I want to know how can i do to make the session dont expire?. i have an cc application that works with sessions, when i left the browser open for a cc while, i dont know maybe 30 minutes, when i try to go into a section it cc throw me an error, for session expire, how can i fic that?. You can control the default lifespan of your session by modifying your php.ini file (look for the Session section, specifically session.gc_maxlifetime). You could also modify this via ini_set(). -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session problem (i think)
Hi, Wednesday, March 17, 2004, 9:43:51 AM, you wrote: NR I am running Apache/2.0.48 (Gentoo/Linux) mod_ssl/2.0.48 OpenSSL/0.9.6k PHP/4.3.4 NR I have a drupal site set up, http://rout.dyndns.org/cagc NR Since some time on Sunday i have had the following error appear at the NR bottom of the page: NR Warning: Unknown(): A session is active. You cannot change NR the session module's ini settings at this time. in Unknown on line NR I then cannot login to the site. Some of the site functionality is there NR (ie you can view the basic pages etc, but anything that needs a login to NR acheive is no good) NR When I search google I seem to find that this is a php error, although I NR cannot see a fix anywhere. NR Can anyone tell me where to look in order to sort this out. I am a php NR newbie, so if there is any other info I need to provide please let me NR know. NR -- NR Nick Rout [EMAIL PROTECTED] Check in php.ini session.auto_start it should be off if you want your own session control. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session problem (i think)
On Wed, 17 Mar 2004 11:03:12 +1000 Tom Rogers [EMAIL PROTECTED] wrote: Hi, Wednesday, March 17, 2004, 9:43:51 AM, you wrote: NR I am running Apache/2.0.48 (Gentoo/Linux) mod_ssl/2.0.48 OpenSSL/0.9.6k PHP/4.3.4 NR I have a drupal site set up, http://rout.dyndns.org/cagc NR Since some time on Sunday i have had the following error appear at the NR bottom of the page: NR Warning: Unknown(): A session is active. You cannot change NR the session module's ini settings at this time. in Unknown on line NR I then cannot login to the site. Some of the site functionality is there NR (ie you can view the basic pages etc, but anything that needs a login to NR acheive is no good) NR When I search google I seem to find that this is a php error, although I NR cannot see a fix anywhere. NR Can anyone tell me where to look in order to sort this out. I am a php NR newbie, so if there is any other info I need to provide please let me NR know. NR -- NR Nick Rout [EMAIL PROTECTED] Check in php.ini session.auto_start it should be off if you want your own session control. Thanks, it is set right, but I see some other things are not. these other bits are set in a .htaccess file in the root of this applications htdocs tree. When I execute a test.php file in the same directory as the .htaccess file I presume the output of phpinfo() should relect whats in the .htaccess file? If not, I assume I should be looking in apache's config files at the AllowOveride stuff? -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Nick Rout [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session problem (i think)
On Wed, 17 Mar 2004 12:37:55 +1000 Tom Rogers [EMAIL PROTECTED] wrote: Hi, Wednesday, March 17, 2004, 12:24:27 PM, you wrote: NR Thanks, it is set right, but I see some other things are not. NR these other bits are set in a .htaccess file in the root of this NR applications htdocs tree. When I execute a test.php file in the same NR directory as the .htaccess file I presume the output of phpinfo() should NR relect whats in the .htaccess file? If not, I assume I should be looking NR in apache's config files at the AllowOveride stuff? NR -- NR Nick Rout [EMAIL PROTECTED] Yes that is the next place to look i added these lines to my apache config and restarted apache: Directory /var/www/localhost/htdocs/cagc/ AllowOverride All /Directory Still the specific settings in .htaccess don't get loaded. any other ideas? -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Nick Rout [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session problem
On Wednesday 04 February 2004 20:59, marc serra wrote: When the header function is called I'm correctly redirected on the right page but all my session variables are destroyed. Try session_write_close() before you redirect. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* I hope something GOOD came in the mail today so I have a REASON to live!! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] session problem
On 04 February 2004 12:59, marc serra contributed these pearls of wisdom: Hi, I'm working on a multi-langage website and i got problem with a fonction which destroy my session :-( I got a file which change my langage like this : // session_start(); if ($_POST['langue']==us) $_SESSION['language']=us; else if ($_POST['langue']==fr) $_SESSION['language']=fr; header(Location: http://.$_SERVER['HTTP_HOST'].$_POST['page_name']); /*/ If you rely on URL rewriting to transmit your session ID, this won't work for header redirects, so you need to manually include the SID value. In any case, this is good defensive programming (in case that configuration parameter ever gets changed!). So your redirect should look like: header(Location: http://.$_SERVER['HTTP_HOST'].$_POST['page_name'].'?'.SID); Cheers! Mike -- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
ok, i am putting it the code in both files, now my first.php is as follows //start the session - in all the pages session_start(); var_dump(ini_get('variables_order')); var_dump(isset($_SESSION)); var_dump($_SESSION); //store it like that $_SESSION[name]= Rinku; - The error msg is string(5) EGPCS bool(true) array(0) { } - second.php is like this -- ? //start the session - in all the pages session_start(); var_dump(ini_get('variables_order')); var_dump(isset($_SESSION)); var_dump($_SESSION); //use it anywher like this echo $_SESSION[name]; ? the error msg is string(5) EGPCS bool(true) array(0) { } Notice: Undefined index: name in C:\Project Codes\Vanderveer\www\testPHP\second.php on line 10 -- Please can u help me now in understanding it ? manisha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
On Tuesday 28 October 2003 08:33, Manisha Sathe wrote: ok, i am putting it the code in both files, now my first.php is as follows [code snipped] The code looks OK. Things you can do to try track down the problem: 1) As always, turn on FULL error reporting and check the logs 2) Verify that your browser is set to accept cookies, or that you have enabled php for transparent sessions support 3) Verify that sessions are being created by looking for them in the directory specified by session.save_path in php.ini -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* The Official Colorado State Vegetable is now the state legislator. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
Your Linux server probably has error_reporting set to 0, which is usually a good idea for production environments. To supress the error messages without modifying your php.ini, do error_reporting(0). Take a look in your php.ini file- the error_reporting directive will have lots of comments around it explaining the concept thoroughly. On Sunday 26 October 2003 01:06 am, Manisha Sathe wrote: I am trying to use session but it seems it does not work on win2k server, the same runs on linux. following is my first php --- ? session_start(); $_SESSION[name]= Manisha; ? -- following is the second php ? session_start(); echo $_SESSION[name]; ? - but it is always giving me following error msg Notice: Undefined index: name in C:\Project Codes\www\testPHP\second.php on line 6 The same thing works well on live Linux server. I checked php.ini options such as session enable / register global etc - both r same. Please help me. Is it a problem with win2k server or did i miss out any thing in php.ini ? Regards Manisha -- Evan Nemerson [EMAIL PROTECTED] -- The people are the only sure reliance for preservation of our liberty. -Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
It works well on linux means it shows me o/p as 'Manisha' but on local Win2kserver, it gives error. I tried to make use of error_reporting(0); in second.php but then screen becomes blank, it does not show me the output as Manisha manisha Evan Nemerson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Your Linux server probably has error_reporting set to 0, which is usually a good idea for production environments. To supress the error messages without modifying your php.ini, do error_reporting(0). Take a look in your php.ini file- the error_reporting directive will have lots of comments around it explaining the concept thoroughly. On Sunday 26 October 2003 01:06 am, Manisha Sathe wrote: I am trying to use session but it seems it does not work on win2k server, the same runs on linux. following is my first php --- ? session_start(); $_SESSION[name]= Manisha; ? -- following is the second php ? session_start(); echo $_SESSION[name]; ? - but it is always giving me following error msg Notice: Undefined index: name in C:\Project Codes\www\testPHP\second.php on line 6 The same thing works well on live Linux server. I checked php.ini options such as session enable / register global etc - both r same. Please help me. Is it a problem with win2k server or did i miss out any thing in php.ini ? Regards Manisha -- Evan Nemerson [EMAIL PROTECTED] -- The people are the only sure reliance for preservation of our liberty. -Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
Hi, do u mean to say put this codes in php ? I tried to put it in second.php following is the msg - -- string(5) EGPCS bool(false) Notice: Undefined variable: _SESSION in C:\Project Codes\Vanderveer\www\testPHP\second.php on line 4 NULL Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Project Codes\Vanderveer\www\testPHP\second.php:2) in C:\Project Codes\Vanderveer\www\testPHP\second.php on line 7 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\Project Codes\Vanderveer\www\testPHP\second.php:2) in C:\Project Codes\Vanderveer\www\testPHP\second.php on line 7 Notice: Undefined index: name in C:\Project Codes\Vanderveer\www\testPHP\second.php on line 10 - I am not that expert in PHP, what all above means ? can u give me a hint now, what is going wrong ? regards manisha Evan Nemerson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] var_dump(ini_get('variables_order')); var_dump(isset($_SESSION)); var_dump($_SESSION); ? On Sunday 26 October 2003 01:43 am, Manisha Sathe wrote: It works well on linux means it shows me o/p as 'Manisha' but on local Win2kserver, it gives error. I tried to make use of error_reporting(0); in second.php but then screen becomes blank, it does not show me the output as Manisha manisha Evan Nemerson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Your Linux server probably has error_reporting set to 0, which is usually a good idea for production environments. To supress the error messages without modifying your php.ini, do error_reporting(0). Take a look in your php.ini file- the error_reporting directive will have lots of comments around it explaining the concept thoroughly. On Sunday 26 October 2003 01:06 am, Manisha Sathe wrote: I am trying to use session but it seems it does not work on win2k server, the same runs on linux. following is my first php --- ? session_start(); $_SESSION[name]= Manisha; ? -- following is the second php ? session_start(); echo $_SESSION[name]; ? - but it is always giving me following error msg Notice: Undefined index: name in C:\Project Codes\www\testPHP\second.php on line 6 The same thing works well on live Linux server. I checked php.ini options such as session enable / register global etc - both r same. Please help me. Is it a problem with win2k server or did i miss out any thing in php.ini ? Regards Manisha -- Evan Nemerson [EMAIL PROTECTED] -- The people are the only sure reliance for preservation of our liberty. -Thomas Jefferson -- Evan Nemerson [EMAIL PROTECTED] -- A popular government, without popular information, or the means of acquiring it, is but a Prologue to a Farce or a Tragedy - or perhaps both. Knowledge will forever govern ignorance, and a people who mean to be their own Governors must arm themselves with the power which knowledge gives. -James Madison -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
Hi, session_start has to be the first command this time. try again and the result will look better, maybe explaining. so it should look like: ? session_start(); var_dump(ini_get('variables_order')); var_dump(isset($_SESSION)); var_dump($_SESSION); ? angel On Sun, 26 Oct 2003 17:47:38 +0800 Manisha Sathe [EMAIL PROTECTED] wrote: Hi, do u mean to say put this codes in php ? I tried to put it in second.php following is the msg - -- string(5) EGPCS bool(false) Notice: Undefined variable: _SESSION in C:\Project Codes\Vanderveer\www\testPHP\second.php on line 4 NULL Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Project Codes\Vanderveer\www\testPHP\second.php:2) in C:\Project Codes\Vanderveer\www\testPHP\second.php on line 7 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\Project Codes\Vanderveer\www\testPHP\second.php:2) in C:\Project Codes\Vanderveer\www\testPHP\second.php on line 7 Notice: Undefined index: name in C:\Project Codes\Vanderveer\www\testPHP\second.php on line 10 - I am not that expert in PHP, what all above means ? can u give me a hint now, what is going wrong ? regards manisha Evan Nemerson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] var_dump(ini_get('variables_order')); var_dump(isset($_SESSION)); var_dump($_SESSION); ? On Sunday 26 October 2003 01:43 am, Manisha Sathe wrote: It works well on linux means it shows me o/p as 'Manisha' but on local Win2kserver, it gives error. I tried to make use of error_reporting(0); in second.php but then screen becomes blank, it does not show me the output as Manisha manisha Evan Nemerson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Your Linux server probably has error_reporting set to 0, which is usually a good idea for production environments. To supress the error messages without modifying your php.ini, do error_reporting(0). Take a look in your php.ini file- the error_reporting directive will have lots of comments around it explaining the concept thoroughly. On Sunday 26 October 2003 01:06 am, Manisha Sathe wrote: I am trying to use session but it seems it does not work on win2k server, the same runs on linux. following is my first php --- ? session_start(); $_SESSION[name]= Manisha; ? -- following is the second php ? session_start(); echo $_SESSION[name]; ? - but it is always giving me following error msg Notice: Undefined index: name in C:\Project Codes\www\testPHP\second.php on line 6 The same thing works well on live Linux server. I checked php.ini options such as session enable / register global etc - both r same. Please help me. Is it a problem with win2k server or did i miss out any thing in php.ini ? Regards Manisha -- Evan Nemerson [EMAIL PROTECTED] -- The people are the only sure reliance for preservation of our liberty. -Thomas Jefferson -- Evan Nemerson [EMAIL PROTECTED] -- A popular government, without popular information, or the means of acquiring it, is but a Prologue to a Farce or a Tragedy - or perhaps both. Knowledge will forever govern ignorance, and a people who mean to be their own Governors must arm themselves with the power which knowledge gives. -James Madison -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session-problem
* Thus wrote Juerg Zgraggen ([EMAIL PROTECTED]): now my problem: i wrote in my navigation-frame this code: ?php if( !isset($_SESSION['testint'] ) ) { $_SESSION['testint'] = 1; } $_SESSION['testint']++; print_r($_SESSION); ? after the print_r() i can see my 'testint'-session-variable on the navigation-site. however on the other frame-site. i do NOT see this 'testint'-session-variable when i reload it. and when i reload the navigation-frame the variable does appear but does NOT increase. isset() always return false!!! when i take a look at the session-file on my Computer, i do NOT find the variable 'testint'... session_start() has been called right? Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session problem in back button
Hi, This will stop them seeing the login once they are in a registered session Only diplay the login form if NOT a registered session variable 'sessionname' (or some other session variable) If (!isset($_SESSION['sessionname'])) { //Display login form code goes here } Cheers. -Original Message- From: murugesan [mailto:[EMAIL PROTECTED] Sent: Monday, August 25, 2003 9:55 AM To: murugesan; Cody Phanekham; [EMAIL PROTECTED] Subject: [PHP] Session problem in back button Hello all, Now i have a problem in back button. After signing in when I click back button It goes to login page. But when I click the forward button it is going to the main page. How can I prevent this. -murugesan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem in back button
Seems confusing. - //include.php session_name(sessionname); session_start(); -- This was added in a separate file and included that file in all the files including index.php In index.php I registered a variable s_authed and initialised it to 0 - //index.php include include.php; session_register(s_authed); $s_authed = 0; // initialize session flag - And after sign up I am authenticating the user in a separate file and setting a flag s_authed to 1 - //auth.php if(check for authentication) { $HTTP_SESSION_VARS['s_authed']=1; } - Now in the main.php I am checking - //main.php if($s_authed==1) { //Display login form code goes here } else { display authentication required; } - This is working fine. Even when I copy and paste the URL to another browser it is showing authentication required page. When I used if (!isset($_SESSION['sessionname'])) { //Display login form code goes here } in main.php it is not working. I mean that it display the page even when I copy and paste URL in a new browser window. Seems like an essay :) Why is it so. Is that my previous method was correct or any mistakes I did? -murugesan - Original Message - From: Paul Fitzpatrick [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, August 26, 2003 10:43 PM Subject: RE: [PHP] Session problem in back button Hi, This will stop them seeing the login once they are in a registered session Only diplay the login form if NOT a registered session variable 'sessionname' (or some other session variable) If (!isset($_SESSION['sessionname'])) { //Display login form code goes here } Cheers. -Original Message- From: murugesan [mailto:[EMAIL PROTECTED] Sent: Monday, August 25, 2003 9:55 AM To: murugesan; Cody Phanekham; [EMAIL PROTECTED] Subject: [PHP] Session problem in back button Hello all, Now i have a problem in back button. After signing in when I click back button It goes to login page. But when I click the forward button it is going to the main page. How can I prevent this. -murugesan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session problem
You have to specify which warnings and errors if you want someone to help -Original Message- From: tana dsasa [mailto:[EMAIL PROTECTED] Sent: 23. júlí 2003 09:58 To: [EMAIL PROTECTED] Subject: [PHP] Session problem I have installed an user-login aplication on my website ( http://www.norbertnet.ro ) but i have problems with session controls. I receive all kinds of warnings and i don't know how to interpret them thanks advanced - Want to chat instantly with your online friends? Get the FREE Yahoo!Messenger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
- Original Message - From: Sourabh G [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, July 13, 2003 11:15 AM Subject: [PHP] Session Problem Hi, I am getting a weird session problem in my site. Background of the Problem: -- My site use sessions for user authentication. Site has a Admin Panel where admin can search users and then through a link (which has login and password appended) login as user. On login as user, session var changes to the new user vars, like user id etc. So, if some one try to access any thing on admin panel, they get error which is quite evident why is that happened. The login user is not a admin any more, its a normal user with no privilege. I came to a conclusion that if I spawn new browser window it takes old session. After trying for hours, I was able to solve this. I started a new session when I login as user by setting session name and storing the other vars. This way I can start the session as needed. After solving this problem I thought I am done. But some thing really weird popped up. The links on the page, like My Account, Change Password goes to admin when I click them. This looks like on clicking the link, Old admin session becoming active and showing the page as a admin. I have no idea why is that happening. I have searched goggle but no result. Is it a browser issue, or php issue, or I am doing something wrong. * I have compiled PHP with trans-sid option. ** I store session in my sql database. I can see the user session active. Ideal Solution:-) -- When I search the user and login as user. Both admin and user session remain alive and I can work on both windows seamlessly. Can Any one point me in the right direction. Thanks This is a problem that many of us have had to deal with.. Session ID's caching and revalidating when the back button is used or a page is revisited. The solution is simple. Don't just destroy the Session, also write over all variables within the session like this.. foreach($_SESSION as $key = $val) { $_SESSION[$key] = ''; } The next time session_start() is called the session file will be emptied. This will ensure that if you click the back button and the Session ID has been cached the session file no longer contains any useful data and there is no possibility that your Login script will revalidate the user. Quite frankly I wouldn't even bother using session_destroy(). It doesn't seem to do anything useful. Good luck, Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session problem
Hi, I have a problem with php sessions. The following code works on my home PC but doesn't work on my office PC. What can be the problem? Its possible you have cookies turned off on your office PC. -Dan Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
You need to start the session at the beginning of the script, or use output buffering. Either: ?php session_start(); require(... ... or ?php ob_start(); require(... ... You're trying to output stuff to the screen (which implicitly sends the headers) then trying to send more headers by calling session_register() (which implicitly calls session_start() ) HTH. Pete. shaun wrote: Hi, I get the following error when using using the following script to authenticate a user. The login form is inside a frameset, is this whats causing th eproblem, and is there a way round this? Warning: Cannot send session cookie - headers already sent by (output started at /home/w/o/workmanagement/public_html/authenticate_user.php:12) in /home/w/o/workmanagement/public_html/authenticate_user.php on line 35 authenticate_user.php: ?php require(dbconnect.php); // Assume user is not authenticated $auth = false; // Formulate the query $query = SELECT * FROM WMS_User WHERE User_Username = '$_POST[username]' AND User_Password = '$_POST[password]'; echo $query; // Execute the query and put results in $result $result = mysql_query( $query ) or die ( 'Unable to execute query.' ); // Get number of rows in $result. $num = mysql_numrows( $result ); if ( $num != 0 ) { // A matching row was found - the user is authenticated. $auth = true; //get the data for the session variables $suser_name = mysql_result($result, 0, User_Name); $suser_password = mysql_result($result, 0, User_Password); $stype_level = mysql_result($result, 0, User_Type); $ses_name = $suser_name; $ses_pass = $suser_password; $ses_level = $stype_level; session_register(ses_name); //this is line 35 session_register(ses_pass); session_register(ses_level); } //if user isn't authenticated redirect to appropriate page if ( ! $auth ) { include(login.php); exit; } //if user is authenticated, include the main menu else{ include(home.php); } //close connection mysql_close(); ? Thanks in as=dvance for your help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
silly me, testing the query (echo $query;) was actually causing the problem! Pete James [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] You need to start the session at the beginning of the script, or use output buffering. Either: ?php session_start(); require(... ... or ?php ob_start(); require(... ... You're trying to output stuff to the screen (which implicitly sends the headers) then trying to send more headers by calling session_register() (which implicitly calls session_start() ) HTH. Pete. shaun wrote: Hi, I get the following error when using using the following script to authenticate a user. The login form is inside a frameset, is this whats causing th eproblem, and is there a way round this? Warning: Cannot send session cookie - headers already sent by (output started at /home/w/o/workmanagement/public_html/authenticate_user.php:12) in /home/w/o/workmanagement/public_html/authenticate_user.php on line 35 authenticate_user.php: ?php require(dbconnect.php); // Assume user is not authenticated $auth = false; // Formulate the query $query = SELECT * FROM WMS_User WHERE User_Username = '$_POST[username]' AND User_Password = '$_POST[password]'; echo $query; // Execute the query and put results in $result $result = mysql_query( $query ) or die ( 'Unable to execute query.' ); // Get number of rows in $result. $num = mysql_numrows( $result ); if ( $num != 0 ) { // A matching row was found - the user is authenticated. $auth = true; //get the data for the session variables $suser_name = mysql_result($result, 0, User_Name); $suser_password = mysql_result($result, 0, User_Password); $stype_level = mysql_result($result, 0, User_Type); $ses_name = $suser_name; $ses_pass = $suser_password; $ses_level = $stype_level; session_register(ses_name); //this is line 35 session_register(ses_pass); session_register(ses_level); } //if user isn't authenticated redirect to appropriate page if ( ! $auth ) { include(login.php); exit; } //if user is authenticated, include the main menu else{ include(home.php); } //close connection mysql_close(); ? Thanks in as=dvance for your help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
In a message dated 1/15/2003 4:18:10 PM Pacific Standard Time, [EMAIL PROTECTED] writes: I am trying to make use of sessions to auhenticate users on the secure parts of the website. Things seems to work fine...but I keep getting this warning. Can some one pl explain what this means ... Warning: Cannot send session cache limiter - headers already sent (output started at /Users/pgarcha/Sites/edit.php:7) in /Users/pgarcha/Sites/edit.php on line 8 Headers must be sent before any other output is sent. This message is telling you that some output was sent on line 7, so now it can't send a header (like for a session) on line 8. You need to open your session before you send any output. Sometimes the output is just a blank space or blank line before the ?php. Janet - Janet Valade Author, PHP MySQL for Dummies -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
- Original Message - From: Pushpinder Singh Garcha [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [PHP] Session Problem Can some one pl explain what this means ... Warning: Cannot send session cache limiter - headers already sent (output started at /Users/pgarcha/Sites/edit.php:7) in /Users/pgarcha/Sites/edit.php on line 8 Take a look here for an explanation: http://www.php-faq.com/#3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
on 02/01/03 9:46 AM, Andrew Williams ([EMAIL PROTECTED]) wrote: I have been messing with PHP 4 on a windows 2000 machine using apache and am having trouble getting sessions to run. I'm going to assume PHP 4.1 I'm also going to assume you're allowing cookies on your browser??? session_register_var.php change your script to: ? // set up a session session_start(); // register the variable to the session $_SESSION['my_favourite_colour'] = blue; // show a hyperlink to get to the next page echo A HREF='show_session_var.php'Click here to go to the next page/A; ? and show_session_var.php change this script to: ? // continue using the session session_start(); // show the variable's value echo My favourite colour is... .$_SESSION['my_favourite_colour']; ? lemme know how you go Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
You don't need to accept cookies for sessions. That's the beauty of it. PHP automatically appends ?PHPSESSID=$sessid to URLs. If you do header(Location: abc) however you will need to add the seession ID to the URL. You cannot read a session var on the same page that you set it I found. To get around this I personally register the sessions vars and also set $_SESSION['whatever'] = 1; That way the next time I call the function I can still look for it under the same name. I use a auth.php include file on eachprotected page. It basically looks to see if you have a session... if not asks you to log in and creates the session for you. If you have a session it just skips all the checking. You will have to tweak this... especiallu since I use my own class for db stuff... but here it is... enjoy. session_start(); $sessid = session_id(); // DEBUGGING $debug=false; if(!(session_is_registered(mysession))){ // Are we coming from the form? if (isset($authaction) $authaction == 1 ) { require_once(/lib/util.php); // Lets clean up the email var $email = strtolower(trim($_POST['email'])); // Create an SQL object $sql = new MySQL_class; $sql-Create(rconline_ca); // Let see if we have this person as a registered user $sql-QueryRow(Select unum, pw, cur_member, pref_lang from user where lower(email) like '$email'); if ($sql-rows == 0) { ErrorMsg(Incorrect e-mail or password.); exit(); } // Compare passwords $row = $sql-data; if (strcmp($_POST['pw'], $row['pw']) != 0 ) { ErrorMsg(Incorrect e-mail or password.); exit(); } // Everything matches up lets register our vars $mysession = array (unum = $row['unum'], email = $email, lang = $row['pref_lang']); setcookie (email, , time() - 7776000, /, .rconline.ca, 0); setcookie (email, $email, time() + 7776000, /, .rconline.ca, 0); session_register(mysession); $_SESSION['mysession']['unum'] = $row['unum']; // update there last login $sql-Update(UPDATE user SET last_login = now() WHERE unum = . $row['unum']); } else { if (isset($HTTP_COOKIE_VARS['email'])){ $email = $HTTP_COOKIE_VARS['email']; } else { $email =; } echo HTML\n; echo HEAD\n; echo TITLE$tags[title]/TITLE\n; echo $tags[style]\n; echo /HEAD\n\n; echo $tags[body]\n\n; echo center\n; echo form method=\POST\ action=\$_SERVER[REQUEST_URI]\\n\n; echo table border=\0\ align=\center\ width=\100%\\n; echo trtd align=\center\ valign=\middle\ width=\100%\ height=\100%\\n; echo table border=\0\ align=\center\\n; echo trtd colspan=\2\ align=\center\\nh3Please log in to use this feature.br; echo iSeuls les membres authentifiés peuvent continuer./i/h3br //td/tr\n; echo trtd align=\center\; // Start of inner table echo table border=\0\; echo tr\n\n; echo td valign=\bottom\ E-Mail: briCourriel:/i/tdtd valign=\bottom\input type=\TEXT\ name=\email\ size=\32\ value=\; echo $email; echo \/td\n; echo /trtr\n; echo td valign=\bottom\Password: briMot-de-passe:/i/tdtd valign=\bottom\input type=\password\ name=\pw\; echo /td/tr\n; echo trtd colspan=\2\ align=\center\\n; echo input type=\hidden\ name=\authaction\ value=\1\\n; echo input type=\submit\ value=\Login\; echo /td/tr/table; // End of innner table echo /td/trtrtd;
Re: [PHP] Session Problem
on 02/01/03 11:42 AM, Michael J. Pawlowsky ([EMAIL PROTECTED]) wrote: You don't need to accept cookies for sessions. That's the beauty of it. PHP automatically appends ?PHPSESSID=$sessid to URLs. only if you compile with trans_sid (he didn't) or if you physically add the SID to each LINK (which he hasn't so far). You will have to tweak this... especiallu since I use my own class for db stuff... but here it is... enjoy. eeek, that's a whole lotta code for him to learn just to try and get sessions working, don't you think?? [mega snip] Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
eeek, that's a whole lotta code for him to learn just to try and get sessions working, don't you think?? [mega snip] Justin Most it is HTML output... But If I'm not mistaken... and I might be... but wasn't this a thread that started about securing web pages? So basically I gave him my solution to it. And I didn't charge the $150/hr consulting fee! :-) . Cheers and HAPPY NEW YEAR! Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
My php.ini file session section looks like this [snip] ; The path for which the cookie is valid. session.cookie_path = c:\tmp On our system, this is /... This is not what you think it is-- this is the WEB path the cookie is valid for... That is, on our system, the browser will send the cookie for all pages under / (IE everything). If you only want the cookie sent back for pages under, say, /secure_directory, you would set this accordingly... It could be PHP is sending the cookie, but your browser isn't sending it back because your view page isn't in the right directory from the browser's point of view... Just a thought, hope it helps... -Matt Sturtz- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
on 02/01/03 11:55 AM, Michael J. Pawlowsky ([EMAIL PROTECTED]) wrote: Most it is HTML output... But If I'm not mistaken... and I might be... but wasn't this a thread that started about securing web pages? So basically I gave him my solution to it. And I didn't charge the $150/hr consulting fee! :-) Wrong thread I think :) securing areas of a site with PHP was the other thread. Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
OK let me give him something simpler to start with No Cookies needed.. Just to test... Make sure you have session.name set to PHPSESSID. Look at phpinfo() output to make sure. Lets have two pages Page 1 start (page1.php) ___ ?php session_start(); $sessid = session_id(); $theSess = This is my session; session_register(theSess); echo a href=\page2.php?PHPSESSID=$sessid\ Next Page a; ? --- Page 1 END Page 2 start (page2.php) ___ ?php session_start(); print_r($_SESSION); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
Just so I know who started this thread, is he even still in this thread, or is this just amongst ourselves now. :-) Hey sorry, what do you expect on the 1st of January. Cheers, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
I started it and yes I am still here and listing to your comments. Thanks Justin for keeping things simple for this simpleton. Ill try your suggestion in a little while Mike, I also at work at the moment and need to slip some of this stuff in whilst I am working. I will keep you posted as to the outcome. By the way its the 2nd of January here! Andrew Just so I know who started this thread, is he even still in this thread, or is this just amongst ourselves now. :-) Hey sorry, what do you expect on the 1st of January. Cheers, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Problem
Mike, This the result Array ( [theSess] = This is my session ) Andrew -Original Message- From: Michael J. Pawlowsky [mailto:[EMAIL PROTECTED]] Sent: Thursday, 2 January 2003 12:07 To: [EMAIL PROTECTED] Subject: Re: [PHP] Session Problem OK let me give him something simpler to start with No Cookies needed.. Just to test... Make sure you have session.name set to PHPSESSID. Look at phpinfo() output to make sure. Lets have two pages Page 1 start (page1.php) ___ ?php session_start(); $sessid = session_id(); $theSess = This is my session; session_register(theSess); echo a href=\page2.php?PHPSESSID=$sessid\ Next Page a; ? --- Page 1 END Page 2 start (page2.php) ___ ?php session_start(); print_r($_SESSION); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Problem
OK so sessions are working... cool... So now you need to track down a your cookie problem. Start of by setting your browser to ask you to accept all cookies. EVEN session cookies. In IE it would be Internet Options-Privacy Tab Advanced... Prompt and override defaults... The take away the ?PHPSESSID=$sessid from the a href in page1. Post the cookie details here. *** REPLY SEPARATOR *** On 02/01/2003 at 12:32 PM Andrew Williams wrote: Mike, This the result Array ( [theSess] = This is my session ) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Problem
Mike, results are Array ( ) Andrew *** REPLY SEPARATOR *** OK so sessions are working... cool... So now you need to track down a your cookie problem. Start of by setting your browser to ask you to accept all cookies. EVEN session cookies. In IE it would be Internet Options-Privacy Tab Advanced... Prompt and override defaults... The take away the ?PHPSESSID=$sessid from the a href in page1. Post the cookie details here. *** REPLY SEPARATOR *** On 02/01/2003 at 12:32 PM Andrew Williams wrote: Mike, This the result Array ( [theSess] = This is my session ) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Problem
OK But did your browser ask you if it was ok to set a cookie? (You did do the changes in privacy) IE or Netsape (what version)? Start with a fresh browser.. meaning close all browser windows and the start up your browser again. We need to see if the problem is setting the cookie or reading it. Mike *** REPLY SEPARATOR *** On 02/01/2003 at 12:56 PM Andrew Williams wrote: Mike, results are Array ( ) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Problem
It appears that it is a problem with the Browser, I did as you suggested and changed the Privacy Settings Advanced to Override Automatic Cookie Handling and selected Prompt for both First and third party cookies. Restarted the browser ie closed all browser windows and restarted IE 6 version 6.0.2800.1106, Cipher strength 128bit. I get no prompt to se the cookie. Session files are still being created in the temp directory. Andrew *** REPLY SEPARATOR *** OK But did your browser ask you if it was ok to set a cookie? (You did do the changes in privacy) IE or Netsape (what version)? Start with a fresh browser.. meaning close all browser windows and the start up your browser again. We need to see if the problem is setting the cookie or reading it. Mike *** REPLY SEPARATOR *** On 02/01/2003 at 12:56 PM Andrew Williams wrote: Mike, results are Array ( ) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
Seems like the remote server has register_globals off. You must use $_GET, $_POST, $_SESSION ... Cesar Aracena wrote: Hi all, I'm having this strange issue with a remote server. I'm trying to create a session control for administrative use which works fine in my PC but once I upload these scripts to that server, it doesn't recognize the $username $password variables and kick me right into the else{} of the login.php script. Here's my code: if ($username $password) { $db_conn = mysql_connect(www.icaam.com.ar, icaam, xxx); mysql_select_db(icaam, $db_conn); $query = SELECT * FROM maraadmins WHERE adminuser = '$username' AND adminpassword = password('$password'); $result = mysql_query($query, $db_conn); if (mysql_num_rows($result) 0) { $row = mysql_fetch_array($result); $valid_admin = $row['adminid']; session_register(valid_admin); header(Location: admin.php); exit; } else { header(Location: ../login.html); exit; } } else { //header(Location: ../login.html); //exit; echo nothing; } Any thoughts?? Thanks in advance, Cesar L. Aracena [EMAIL PROTECTED] [EMAIL PROTECTED] (0299) 156-356688 Neuquén (8300) Capital Argentina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem
Is it your register_globals setting? ---John Holmes... - Original Message - From: Cesar Aracena [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, November 22, 2002 2:59 PM Subject: [PHP] Session Problem Hi all, I'm having this strange issue with a remote server. I'm trying to create a session control for administrative use which works fine in my PC but once I upload these scripts to that server, it doesn't recognize the $username $password variables and kick me right into the else{} of the login.php script. Here's my code: if ($username $password) { $db_conn = mysql_connect(www.icaam.com.ar, icaam, xxx); mysql_select_db(icaam, $db_conn); $query = SELECT * FROM maraadmins WHERE adminuser = '$username' AND adminpassword = password('$password'); $result = mysql_query($query, $db_conn); if (mysql_num_rows($result) 0) { $row = mysql_fetch_array($result); $valid_admin = $row['adminid']; session_register(valid_admin); header(Location: admin.php); exit; } else { header(Location: ../login.html); exit; } } else { //header(Location: ../login.html); //exit; echo nothing; } Any thoughts?? Thanks in advance, Cesar L. Aracena [EMAIL PROTECTED] [EMAIL PROTECTED] (0299) 156-356688 Neuquén (8300) Capital Argentina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
Sorry... session.cookie_domain in php.ini Make sure you can also write to /tmp -js Ferhat Can wrote: Dear All, I have a problem and need your help. I use PHP 4.2.3, Apache 1.3.27 and a local version of Red Hat. Here is the problem: I have a web site that depends on Session, but the Session ID seems to be regnerated evertime I refresh the page. I have tried different versions of PHP with different versions of Apache but the problem remained. I am giving some links on my server showing my system variables, and the session example given in the manual. Here is the link: http://linuxserver.pergelcrm.com/system.php http://linuxserver.pergelcrm.com/system.php Thanks in advance for your help. Ferhat Can -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
Try setting the session.domain in your php.ini... -js Ferhat Can wrote: Dear All, I have a problem and need your help. I use PHP 4.2.3, Apache 1.3.27 and a local version of Red Hat. Here is the problem: I have a web site that depends on Session, but the Session ID seems to be regnerated evertime I refresh the page. I have tried different versions of PHP with different versions of Apache but the problem remained. I am giving some links on my server showing my system variables, and the session example given in the manual. Here is the link: http://linuxserver.pergelcrm.com/system.php http://linuxserver.pergelcrm.com/system.php Thanks in advance for your help. Ferhat Can -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
Thank you for replying Jonathan, I set the session.cookie_domain in php.ini but it didn't work. I have too many session files in my /tmp directory. Everytime I refresh the page a new session file is created unfortunately. Ferhat Can - Original Message - From: Jonathan Sharp [EMAIL PROTECTED] To: Ferhat Can [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, October 15, 2002 6:55 PM Subject: Re: [PHP] Session problem Sorry... session.cookie_domain in php.ini Make sure you can also write to /tmp -js Ferhat Can wrote: Dear All, I have a problem and need your help. I use PHP 4.2.3, Apache 1.3.27 and a local version of Red Hat. Here is the problem: I have a web site that depends on Session, but the Session ID seems to be regnerated evertime I refresh the page. I have tried different versions of PHP with different versions of Apache but the problem remained. I am giving some links on my server showing my system variables, and the session example given in the manual. Here is the link: http://linuxserver.pergelcrm.com/system.php http://linuxserver.pergelcrm.com/system.php Thanks in advance for your help. Ferhat Can -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
I believe it's a cookie issue, as when I hard code in an active session: http://linuxserver.pergelcrm.com/count.php?PHPSESSID=7bf48f99e86e2d3d401c57c4f39dabbc it counts correctly. Oops! Try this... session.cookie_domain=linuxserver.pergelcrm.com NOT www.cardiologicforum.com Cheers, -js Ferhat Can wrote: Thank you for replying Jonathan, I set the session.cookie_domain in php.ini but it didn't work. I have too many session files in my /tmp directory. Everytime I refresh the page a new session file is created unfortunately. Ferhat Can - Original Message - From: Jonathan Sharp [EMAIL PROTECTED] To: Ferhat Can [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, October 15, 2002 6:55 PM Subject: Re: [PHP] Session problem Sorry... session.cookie_domain in php.ini Make sure you can also write to /tmp -js Ferhat Can wrote: Dear All, I have a problem and need your help. I use PHP 4.2.3, Apache 1.3.27 and a local version of Red Hat. Here is the problem: I have a web site that depends on Session, but the Session ID seems to be regnerated evertime I refresh the page. I have tried different versions of PHP with different versions of Apache but the problem remained. I am giving some links on my server showing my system variables, and the session example given in the manual. Here is the link: http://linuxserver.pergelcrm.com/system.php http://linuxserver.pergelcrm.com/system.php Thanks in advance for your help. Ferhat Can -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
h I dunno why but if I returned $data from my function and registered it out side the function it works fine and yes my session_start() is above my function John I am having problems with my sessions. This function registered my username password and userid in the session no problem. function login_chk($username, $password){ global $user_id; $user_res = mysql_query(SELECT * FROM fan_users WHERE name = '$username' and password ='$password') or die(Line 21 .mysql_error()); $count = mysql_num_rows($user_res); if($count ==1){ $user_data = mysql_fetch_row($user_res); $user_id = $user_data[0]; if(!session_is_registered(user_id)) session_register(user_id); if(!session_is_registered(username)) session_register(username); if(!session_is_registered(password)) session_register(password); $ok = 2; } else $ok =1; return $ok; }//E-OF login_chk() But this function will not register the details in the session. It registeres the variable but puts an ! before it. function get_data($user_id){ global $user_id; $data_res = mysql_query(SELECT t.*, l.* FROM fan_teams as t, fan_league as l WHERE t.league_id = l.lid AND user_id =$user_id) or die(Line 93 .mysql_error()); $count = mysql_num_rows($data_res); if($count != 1){ setup_team_html($user_id); exit(); } else{ $data = mysql_fetch_row($data_res); if(!session_is_registered(data)) session_register(data); } }//E-OF get_data($user_id) The $data array is definatly an array as I have done foreach echo tests and it dumps the information i am needing. but it won't put it in the session. Would it have anything to do with me testing it on my windoze box? Cheers John Wards SportNetwork.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
I think this one worked because if($count ==1){ $user_data = mysql_fetch_row($user_res); $user_id = $user_data[0]; // --- of this if(!session_is_registered(user_id)) session_register(user_id); if(!session_is_registered(username)) session_register(username); if(!session_is_registered(password)) session_register(password); $ok = 2; } The way you did here is kind of different from the above. else{ $data = mysql_fetch_row($data_res); if(!session_is_registered(data)) session_register(data); // [trouble*] } }//E-OF get_data($user_id) The $data array is definatly an array as I have done foreach echo tests and it dumps the information i am needing. but it won't put it in the session. *The reason _I think_ is because: quoted Note: It is not currently possible to register resource variables in a session. For example, you can not create a connection to a database and store the connection id as a session variable and expect the connection to still be valid the next time the session is restored. PHP functions that return a resource are identified by having a return type of resource in their function definitions. A list of functions that return resources are available in the resource types appendix. /quoted from here: http://www.php.net/manual/en/function.session-register.php - E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] session problem
Just thought I'd mail it here. It's a reported bug, Bug #16263. Discovered (after hours of agonizing). martin, values were being assigned and passed :) thanks anyway. -Original Message- From: Martin Clifford [mailto:[EMAIL PROTECTED]] Sent: Monday, July 08, 2002 6:29 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] session problem You have to set the variables before using session_register(). ?php session_start(); $var = Yo; session_register(var); ? If you try registering a variable that has no value, then of course no value can be carried over to the next page. :o) Martin Naintara Jain [EMAIL PROTECTED] 07/06/02 09:08PM I am storing some values in session variables. The behavior of the session is pretty unpredictable. On the first page I begin with: session_name(aname) session_start() session_register(var1,var2) In another page I check for existing value of session variable var2. In the next page I have the following code: session_name(aname) session_start() if(($var2)== || !isset($var2)) invalid But the strange thing is that the session value is not accessible in the other page. I have tried passing the session id though session_id() in the URL. Session handling has been giving me some trouble (windows 2000, IIS) The strange thing is that it works some times. Can anyone give any pointers? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
On Mon, 15 Apr 2002, Torkil Johnsen wrote: I get this errormessage when trying to make my logon work: Warning: Cannot send session cache limiter - headers already sent (output started at /path/to/my/little/session.inc:9) in /path/to/my/little/session.inc on line 10 line 10 contains: session_start(); Put session_start(); at the very top of your script - make sure there is no whitespace at the top as well. Cheers, Nick Winfield. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problem
The message means that that your script produced some output before the session_start. You have to use session_start before any output. The message shows where the output was started (line 9 of the given file). Sometimes output is started accidentally by having a blank space before your ?php tag. Janet - Original Message - From: Torkil Johnsen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 15, 2002 2:07 AM Subject: [PHP] Session problem I get this errormessage when trying to make my logon work: Warning: Cannot send session cache limiter - headers already sent (output started at /path/to/my/little/session.inc:9) in /path/to/my/little/session.inc on line 10 line 10 contains: session_start(); It does however seem like I am logged in, becase at the bottom of my page, my logout button is appearing. (which it is only supposed to do if session_is_registered(session_id) When clickign the logout button I get this message: Warning: Trying to destroy uninitialized session in /path/to/my/little/session.inc on line 37 Where line 37 says:session_destroy(); Anyone...? Anyone have any links to any really good php session examples? I have read quite a few of them now... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION PROBLEM
On Tuesday, March 19, 2002, at 02:56 PM, karthikeyan wrote: What does this error means - Warning: Cannot send session cookie - headers already sent by (output started at /home/web/public_html/karthik1.php:7) in /home/web/public_html/karthik1.php on line 35 Warning: Cannot send session cache limiter - headers already sent (output started at /home/web/public_html/karthik1.php:7) in /home/web/public_html/karthik1.php on line 35 Are you trying to start a session after the headers have already been sent? Usually this happens on accident if you have some HTML whitespace being sent on accident (an extra line in an .inc file, or an extra line before the ?php at the top of the page...). Make sure your session_start() function is before any HTML output, whitespace or no. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session problem
What do you mean : session persist? Whe you close the browser the file(the most common case) is not deleted till the session expires. So if the expire time is 30 min it will stay in the /tmp for minimum 30 mins(the session garbage collector is not started on every request). The cookie which is the session_id(PHPSESSID) is set to be valid till the browser is closed. After browser closing it is no valid for the browser. Best regards, Andre Hristov P.S. Back from the exams hell...Ready for helping again. - Original Message - From: Rodrigo Peres [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Thursday, February 14, 2002 7:25 PM Subject: [PHP] session problem Hi list, I've made this script in order to solve the problem with reload button that I've posted. My idea is to register in a session the id, them check if it exists, if so don't insert again. But even if I quit the browser the session persists. Why?? ps: this is an include in the main page where I use session_start(); if(!$visita) { $visita = array(); } if(!in_array($celebID,$visita)) { $sql_log = INSERT INTO log_hits (logID,log_date,log_ip,log_referrer,log_celeb,log_url) VALUES('',now(),'$REMOTE_ADDR','$HTTP_REFERER','$celebID','$REQUEST_URI'); $query_log = new Query($conexao); $query_log-executa($sql_log); array_push($visita,$celebID); session_register('visita'); } Thank's Rodrigo -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session problem Warning: open(/tmp\sess_..., O_RDWR) failed: m (2)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then Freddy blurted I am getting the folloing error whenever I try to open a session. Warning: open(/tmp\sess_0929ece4254c982def371c8f1ccd8164, O_RDWR) failed: m (2) It seems like a permissions issue to me but I do not know where to look for addressing the problem. I am using apache on win2k. Win2k doesn't /have/ permissions. Does it? Check in your php.ini for (i think) the session_save_path or something very similar. I'll bet /tmp doesn't exist on your machine and you just need to put a path liek C:\\Windows\temp or something. - -- Nick Wilson Tel:+45 3325 0688 Fax:+45 3325 0677 Web:www.explodingnet.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE8UG43HpvrrTa6L5oRAmTRAJ9DMZMNu54HgIuf6t7tbxZSDSS/9wCgmvRM TiZKEvsXZvV4MvW6mAsY8rg= =P7KG -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] session problem Warning: open(/tmp\sess_..., O_RDWR) failed: m (2)
Win2k is the same as NT and does, indeed, have permissions. Very different from *nix permissions but they do exist. Mike Frazer Nick Wilson [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then Freddy blurted I am getting the folloing error whenever I try to open a session. Warning: open(/tmp\sess_0929ece4254c982def371c8f1ccd8164, O_RDWR) failed: m (2) It seems like a permissions issue to me but I do not know where to look for addressing the problem. I am using apache on win2k. Win2k doesn't /have/ permissions. Does it? Check in your php.ini for (i think) the session_save_path or something very similar. I'll bet /tmp doesn't exist on your machine and you just need to put a path liek C:\\Windows\temp or something. - -- Nick Wilson Tel: +45 3325 0688 Fax: +45 3325 0677 Web: www.explodingnet.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE8UG43HpvrrTa6L5oRAmTRAJ9DMZMNu54HgIuf6t7tbxZSDSS/9wCgmvRM TiZKEvsXZvV4MvW6mAsY8rg= =P7KG -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] session problem Warning: open(/tmp\sess_..., O_RDWR) failed: m (2)
Seems that I had a few php.ini files finally found the right one and changed the path in it and deleted the others. Thanks Nick Wilson wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then Freddy blurted I am getting the folloing error whenever I try to open a session. Warning: open(/tmp\sess_0929ece4254c982def371c8f1ccd8164, O_RDWR) failed: m (2) It seems like a permissions issue to me but I do not know where to look for addressing the problem. I am using apache on win2k. Win2k doesn't /have/ permissions. Does it? Check in your php.ini for (i think) the session_save_path or something very similar. I'll bet /tmp doesn't exist on your machine and you just need to put a path liek C:\\Windows\temp or something. - -- Nick Wilson Tel:+45 3325 0688 Fax:+45 3325 0677 Web:www.explodingnet.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE8UG43HpvrrTa6L5oRAmTRAJ9DMZMNu54HgIuf6t7tbxZSDSS/9wCgmvRM TiZKEvsXZvV4MvW6mAsY8rg= =P7KG -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Session problem
Nope. That is just the problem. session_destroy() only destroys the data inside the session. Not the id. But i actually solved it now. I am using the same algorithm as php itself to create a new id everytime the page is loaded: session_id( md5( uniqid( , 1 ) ) ); session_start(); - Daniel -Original Message- From: R'twick Niceorgaw [mailto:[EMAIL PROTECTED]] Sent: den 16 november 2001 15:40 To: Daniel Alsén Subject: Re: [PHP] Session problem I think you can set a new session id using session_start() so if you need a new id just destroy the old one using session_destroy() then call sessio_start(your new id) and that should work fine now. - Original Message - From: Daniel Alsén [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Friday, November 16, 2001 9:05 AM Subject: [PHP] Session problem Hi, i am writing a simple postcard-script. I use php 4 sessions and stores the data in MySql with the sessionid as a unique id for the card. The problem is - i can´t send more than one card with the same id. I can´t find any way to get a new session id without closing the browser. In the manual there only seems to be functions to unset or unregister the actual data inside the session - not the id itself. Any ideas? Regards # Daniel Alsén| www.mindbash.com # # [EMAIL PROTECTED] | +46 704 86 14 92 # # ICQ: 63006462 | # -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Session Problem
Try session_register(count); Rudolf Visagie [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 24 August 2001 04:42 To: [EMAIL PROTECTED] Subject: [PHP] Session Problem I can't get session variables to work I know this has been done to death in the past, but I've looked on php.net, and google for a solution, have tried the suggestions, and seem to fix it. My php session settings are as follows: NameLocal Global settings session.auto_start Off Off session.cache_expire180 180 session.cache_limiter nocache nocache session.cookie_domain no valueno value session.cookie_lifetime 0 0 session.cookie_path / / session.entropy_fileno valueno value session.entropy_length 0 0 session.gc_maxlifetime 14401440 session.gc_probability 1 1 session.namePHPSESSID PHPSESSID session.referer_check no valueno value session.save_handlerfiles files session.save_path /tmp/tmp session.serialize_handler php php session.use_cookies On On The code I'm using to test is as follows: ?php session_start(); echo COUNT{$count}; if (!isset($count)) { echo registering session; session_register($count); $count=1; } else { $count++; echo $count; } ? The output is as follows: COUNTregistering session Refreshing shows the same output My /tmp directory exists and has the following permissions. drwxrwxrwt 3 root root 4096 Aug 24 10:40 tmp What should I be looking for? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Session Problem
The simple things... Now I feel stupid. Baaie dankie Rudolf. (I'm an ex Capetownian now in Shanghai,China) Note to self, read manual * C A R E F U L L Y * -Original Message- From: Rudolf Visagie [mailto:[EMAIL PROTECTED]] Sent: August 24, 2001 1:43 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: [PHP] Session Problem Try session_register(count); Rudolf Visagie [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 24 August 2001 04:42 To: [EMAIL PROTECTED] Subject: [PHP] Session Problem I can't get session variables to work I know this has been done to death in the past, but I've looked on php.net, and google for a solution, have tried the suggestions, and seem to fix it. My php session settings are as follows: NameLocal Global settings session.auto_start Off Off session.cache_expire180 180 session.cache_limiter nocache nocache session.cookie_domain no valueno value session.cookie_lifetime 0 0 session.cookie_path / / session.entropy_fileno valueno value session.entropy_length 0 0 session.gc_maxlifetime 14401440 session.gc_probability 1 1 session.namePHPSESSID PHPSESSID session.referer_check no valueno value session.save_handlerfiles files session.save_path /tmp/tmp session.serialize_handler php php session.use_cookies On On The code I'm using to test is as follows: ?php session_start(); echo COUNT{$count}; if (!isset($count)) { echo registering session; session_register($count); $count=1; } else { $count++; echo $count; } ? The output is as follows: COUNTregistering session Refreshing shows the same output My /tmp directory exists and has the following permissions. drwxrwxrwt 3 root root 4096 Aug 24 10:40 tmp What should I be looking for? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]