Languages :: PHP :: Session variables |
|||
| By: PHP newbee |
Date: 13/05/2003 00:00:00 |
Points: 125 | Status: Answered Quality : Excellent |
|
Hi, I'm teaching myself PHP but having problems with sessions. I've read all previous posts regarding this but haven't solved my problem. At the top of every PHP page I have: session_start(); Now, from what I understand, as I am using PHP v4.3.1, to set a session variable I can do: $_SESSION['MyVariable'] = "Hello World"; I can then access this session variable from that same page using: echo $_SESSION['MyVariable']; However, when I try and retrieve this session variable on another page, it doesn't find it - it doesn't seem to have been persisted in the session. I've read various contradicting solutions which don't seem to help. Thanks in advance for any help. |
|||
| By: VGR | Date: 13/05/2003 00:24:00 | Type : Comment |
|
| you are 100% right show me at least two pages exposing the problem |
|||
| By: VGR | Date: 13/05/2003 00:25:00 | Type : Comment |
|
| I suspect a silly string syntax error when retrieving the value |
|||
| By: PHP newbee | Date: 13/05/2003 00:33:00 | Type : Comment |
|
| page1.php: ----------- <? session_start(); $_SESSION['MyVariable'] = "Hello World"; ?> <HTML> <HEAD></HEAD> <BODY> <A HREF="page2.php">GO TO NEXT PAGE</A> </BODY> </HTML> page2.php --------- <? session_start(); ?> <HTML> <HEAD></HEAD> <BODY> <? echo "The value of the session variable: MyVariable is: " . $_SESSION['MyVariable']; ?> </BODY> </HTML> |
|||
| By: VGR | Date: 13/05/2003 00:41:00 | Type : Comment |
|
| nothing to say. It's perfect AFAIK. I tested it and got : The value of the session variable: MyVariable is: Hello World I'm not surprised 8-) |
|||
| By: PHP newbee | Date: 13/05/2003 00:44:00 | Type : Comment |
|
| I thought it was fine....it's not exactly a complicated bit of code! It just doesn't work for me. I can't work out why. Could it be some setting in the php.ini file? |
|||
| By: VGR | Date: 13/05/2003 00:50:00 | Type : Comment |
|
| surely, I can't see anything else possible. I thought sessions were active by default |
|||
| By: VGR | Date: 13/05/2003 00:51:00 | Type : Comment |
|
| I don't even ask you the contents of the [Session] section of php.ini, I'm +/- sure it's ok |
|||
| By: VGR | Date: 13/05/2003 00:52:00 | Type : Answer |
|
| may-be I've an idea : isn't the drive you installed the session data on (session.save_path) a FAT16 drive ? |
|||
| By: PHP newbee | Date: 13/05/2003 00:59:00 | Type : Comment |
|
| It's a FAT32 drive. I haven't played around with the ini file so it should be fine. Rapidly losing hair and wondering if it's such a good idea deviating from ASP! |
|||
| By: PHP newbee | Date: 13/05/2003 01:03:00 | Type : Comment |
|
| I'm running PHP on Windows 2000....could that have anything to with it? |
|||
| By: PHP newbee | Date: 13/05/2003 01:14:00 | Type : Comment |
|
| Aahhh, i've fixed it :) As I'm running PHP on Windows 2000, I needed to change the session.save_path in the ini file to: C:\WINNT\temp Thanks for your input though. |
|||
| By: VGR | Date: 13/05/2003 01:15:00 | Type : Comment |
|
| yes... |
|||
| By: carchitect | Date: 14/05/2003 05:33:00 | Type : Comment |
|
| no don't delete because VGR gave you hint for that may-be I've an idea : isn't the drive you installed the session data on (session.save_path) a FAT16 drive ? you should award him points |
|||
| By: PHP newbee | Date: 14/05/2003 18:35:00 | Type : Comment |
|
| The "hint" you gave didn't directly help me gain the solution. When you posted it, it gave me the impression that the problem could have been possibly due to having a FAT16 drive. I found the solution going through the php.ini file line by line and reading all the comments that explain what all the settings do. This lead me to the solution that if running on Windows, you have to change the save_session.path to use C:\WINNT\temp in my case. |
|||
| By: VGR | Date: 14/05/2003 18:45:00 | Type : Comment |
|
| no in fact, I expected you to have already put something for windows (default is for linux/*nix) in session.save_path I didn't expect php.ini to be wrong on that point. I suggested a mistake very annoying and already asked twice on EEE, and that I had too (the FAT16 story, related to the impossibility for PHP to get atime(), ctime() etc on session files) It's true that my sugegstion lead you directly to the right php.ini variable, but for an other reason than the real one. Do as you wish "fais ce que vouldras" (Gargantua, François Rabelais) <A HREF="http://www4.desales.edu/~salesian/rabelais.html">http://www4.desales.edu/~salesian/rabelais.html</a> |
|||
| By: VGR | Date: 14/05/2003 20:07:00 | Type : Comment |
|
| Monseigneur est trop bon. Touchez ma bosse, Monseigneur... |
|||
| By: PHP newbee | Date: 15/05/2003 18:21:00 | Type : Comment |
|
| Now that's not very nice.....insulting people is not very professional. |
|||
| By: VGR | Date: 15/05/2003 18:54:00 | Type : Comment |
|
| you're not insulted. Translated, it says "Sir is too god". Nothing less, nothing more. It's a famous quote from a famous movie. |
|||
| By: PHP newbee | Date: 15/05/2003 18:57:00 | Type : Comment |
|
| Maybe I translated the second bit wrong... "Touchez ma bosse..." ?? |
|||
| By: VGR | Date: 15/05/2003 19:40:00 | Type : Comment |
|
| touch my boss (hump) the person saying this is a "bossu" (hump-affected man) and touching the "hump" bears good luck. Thus , thanking his interlocutor ("you are too good"), he invites him to get good luck by touching his hump. is that better ? |
|||
| By: VGR | Date: 15/05/2003 19:56:00 | Type : Comment |
|
| "Le Bossu" est avant tout un roman de Paul Féval (1857). Mais il a été adpté au cinéma en 1913, puis 6 autres fois. Les plus célèbres versions sont celles de 44 avec Pierre Blanchar, et de 59 d'André Hunebelle, avec Jean Marais. Enfin en 67, une version télé avec Jean Piat eu un grand succès. and actually someone is raising 143 million French Francs 21,79 million euros, roughly 19,12 million US dollars) to adapt it a 7th time for TV (Canam+ and TF1) ; Lagardère will be played by Daniel Auteuil. <A HREF="http://www.ecrannoir.fr/films/97/lebossu/histoire.htm">http://www.ecrannoir.fr/films/97/lebossu/histoire.htm</a> <A HREF="http://www.amazon.fr/exec/obidos/ASIN/B00007GZID/">http://www.amazon.fr/exec/obidos/ASIN/B00007GZID/</a> |
|||
| By: PHP newbee | Date: 15/05/2003 19:57:00 | Type : Comment |
|
| lol....well that went straight over my head! |
|||
| By: PHP newbee | Date: 15/05/2003 20:02:00 | Type : Comment |
|
| je parle un petit peu de francais et je trouve c'est assez difficult de comprends. (I think) |
|||
| By: VGR | Date: 15/05/2003 20:13:00 | Type : Comment |
|
| is "hump" the correct word ? And how is called the man having one ? |
|||
| By: PHP newbee | Date: 15/05/2003 20:17:00 | Type : Comment |
|
| i don't know...i translated it as "Touch my lump / bump"! |
|||
| By: VGR | Date: 15/05/2003 20:33:00 | Type : Comment |
|
| I don't even know what is a lump (I know "lung"), and I think the "bump" is the bottom, no ? |
|||
| By: PHP newbee | Date: 15/05/2003 20:36:00 | Type : Comment |
|
| I think I'll quit here before my brain gives in! Cheers |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








