![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
King of Portal
|
Session question
This will be a somewhat vague inquiry as I don't quite understand the problem. I have some code which uses the session_start() function. It works fine on my development environment when I test it basically I set a $_SESSION variable and then I check to see that it is set in another page. On my PC it works fine, but on my online server no success. Any idea why the disparity? Or suggestions as to how to find out why?
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis Last edited by grimpirate; Nov 29th, 2006 at 1:34 AM. |
|
|
|
|
|
#2 |
|
King of Portal
|
Here's an example which I tested on my home computer and on the webserver.
test1.php[PHP]<?php session_start(); $_SESSION['test'] = 'haha'; ?> <html> <head> <meta http-equiv="refresh" content="1;test2.php"> </head> <body> </body> </html>[/PHP] test2.php[PHP]<?php session_start(); ?> <html> <head> </head> <body> <?php if(IsSet($_SESSION['test'])){ echo 'SET'; } ?> </body> </html>[/PHP] The string SET is not echoed onto the browser in test2.php
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis |
|
|
|
|
|
#3 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
on a whim, do a phpinfo() and make sure sessions are enabled.
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
#4 |
|
King of Portal
|
Hey Jimbo, nice to see you again. I gave up on getting that session stuff to work. It was working before and just suddenly stopped and rather than dealing with it I just gave up. Rather than using sessions I'll just store cookies on my server which recognize people by their IP. Already been done and the code I had working with sessions previously now works that way. Not necessarily an effective workaround, but I think it will prove pretty useful in its own right. I needed to get something done so that the forum I was coding would still be functional. I think this will be more compatible with PHP servers rather than using sessions as a lot of them restrict this option.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis |
|
|
|
|
|
#5 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
What if you have people logging in (or accessing the side at least) from behind a common NAT box? Going by IP doesn't work so well in that case. Using cookies on their computers also falls by the wayside if they have cookies disabled. 'Course, you can just state that cookies have to be enabled for your site, but that's up to you.
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
#6 |
|
King of Portal
|
Well the cookie is structured as follows and receives a unique name. This unique name for the cookie is passed through the browser URL via the $_GET superglobal array. Here's the structure of the cookie.
username0x1Eipaddress
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis |
|
|
|
|
|
#7 |
|
Newbie
Join Date: Oct 2006
Posts: 16
Rep Power: 0
![]() |
Besides checking the phpinfo() to ensure that you can use sessions, what is your server setup like?
http://www.480x.com/2006/05/23/php-o...anced-servers/ PHP sessions don't work very well on load balanced setups. There may be additional complications on your server setup that deal the death blow to sessions. - Sean |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Session Question | Tedd | PHP | 8 | Jun 19th, 2006 7:43 PM |
| Attitudes | Oddball | Coder's Corner Lounge | 29 | Mar 18th, 2006 9:34 PM |
| How to post a question | nnxion | C++ | 10 | Jun 3rd, 2005 11:53 AM |
| How to post a question | nnxion | C | 0 | Jun 3rd, 2005 8:55 AM |
| session help | magic_e | PHP | 13 | Mar 1st, 2005 5:17 PM |