How Do Different Sessions Work? Multiple Sessions
I use a messageboard which uses sessions.
I have a login script which uses sessions.
I have a charting app which uses sessions.
How does PHP handle this? Does it create three different sessions or is everything handled by the one session file? In other words, is it working like magic and I don't need to worry about it.
What I'm confused with is that at the start of the login script there is a start_session() and other session related stuff. On logout, the session is destroyed.
Now does this affect the start_session() of the other scripts?
View Complete Forum Thread with Replies
Related Forum Messages:
Can't Get Sessions To Work
I can't seem to get my sessions to work and after having spent a couple of hours searching the forums and recoding but still haven't sorted it out. I am trying to set a session with the user login information submitted by a form and checked against a database. My login form sends the info to a validation file where I had hoped to set the session variable. If the login is not correct the user is redirected back to an error page. I also have a sessionFile.php where I have stored the code to check if the session is not set, which I want to include on each page to prevent a user accessing the page without logging in. Code:
View Replies !
Can't Seem To Get Sessions To Work.
If I use the default directory in the php.ini (C:PHPsessiondata) my session works fine. If I set the path to a different dir (cgi-bin mp) it writes the session file there properly but puts nothing in it. I need to be able to define the dir when I take the program to my Internet Provider. They give you a special dir. I have tried it and get the same results as above. Code:
View Replies !
Sessions Don't Work
With PHP 5 the default setting for register globals is off. This means that sessions variables don't work (see quote below). So, I have a website that makes plenty of use of sessions, which has stopped working properly. The question is, what changes do i have to make to ensure I can still make use of them or something similar to them? "If you want your script to work regardless of register_globals,    you need to instead use the $_SESSION array as $_SESSION entries    are automatically registered. If your script uses session_register(),    it will not work in environments where the PHP directive    register_globals is disabled."
View Replies !
Sessions Only Work On Localhost
I've created a website using Win2000 & apache. The site works fine there. I than wanted to move the website on a redhat8 server (using it in a production envoronment), but there I am getting trouble with the sessions I use in the site. The problem is on the redhat localhost, sessions works fine, but throughout the office network (using win2000 machines) pages don't work because it appears that sessions contain no data or 'wrong' data. E.g., A user enters a certain area of the website (the areas I organized using directories). Everytime a user enters a particular direcory I set up a sessions for the user in default.php of the specific directory. I do this because I want the user to enter a directory through the directory's default.php. I create a sesion called $_SESSION['areasection']=", and give it the value of the directory (a,b,c,d,e,...) example: Code:
View Replies !
Do Sessions Work With POSTDATA?
I use sessions on my site through SSL for my user area. Now does POSTDATA work with sessions in the sense that session data is passed when POSTDATA is sent? If not, how can I combat hacks?
View Replies !
Possible For Sessions To Work Under PHP5 And Not Under PHP4.
I'm writing an web application with PHP/MySQL. I used PHP5 but believed to use code that would work also under PHP4. However when I tried my application under PHP4 I got the warning that the headers are already sent and my session did not work. I do understand that I have to send the headers before anything else. But does anyone know what kind of difference between PHP4 and PHP5 makes it possible for sessions to work under PHP5 and not under PHP4.
View Replies !
Make Sessions Work Across Subdomains?
Is there anyway to make sessions work across subdomains? When users visit my site they are directed to auth.site.com to login or register but when they login they use site.com but the sessions dont seem to follow with the change
View Replies !
Problems Gettin My Sessions To Work
I am having problems gettin my sessions to work, and have tried the basic scropt below to tray and resolve it. Is the code below incorrect? <?php session_start(); if(isset($_SESSION['views'])) $_SESSION['views'] = $_SESSION['views']+ 1; else $_SESSION['views'] = 1; echo "views = ". $_SESSION['views']; ?> <a href="view.php">test</a>
View Replies !
How Do Sessions Work Cos Mine Isnt Working?
How do sessions work cos mine isnt working i got this: on a different page i have : $_SESSION['referer'] = '1'; then: if ($_SESSION['referer'] == '1'){ include ("include.php"); } but when i echo session it is blank =/ what did i do wrong.. i got many other sessions on the go so it should work..
View Replies !
Unable To Get Sessions To Work Properly With The Combination Apache 2.0.49 / PHP 4.3.6 / Windows XP.
I'm unable to get sessions to work properly with the combination Apache 2.0.49 / PHP 4.3.6 / Windows XP. The data is written to the correct place (according to php.ini), but they are not read in again on the next page. The following script illustrates the problem: <? session_start(); if (!isset($_SESSION['count'])) { $_SESSION['count'] = 0; } else { $_SESSION['count']++; } echo $_SESSION['count']; ?> Each time the page is reloaded, the output should increment by one, i.e. it should be: 0,1,2,..., and it indeed works this way on my laptop with Apache 1.3.29 / PHP 4.3.6 / Windows XP, but, alas, not with the newest Apache2.
View Replies !
Allow Multiple Sessions
I'm developing a gameserver admin site , and some advanced user will rent multiple servers, therefore it would be nice to allow multiple sessions. Right now, when someone logs in as user "sam", and they want to log in as "joe" they will lose connection to the "sam" account.
View Replies !
Multiple Sessions
I have a script which checks whether a user is logged in and on which level. If he is not logged in, he will get the login screen. My problem is that the script works on the server of the ISP, but not on my local machine. I checked me php.ini files and also phpinfo on the ISP server. But what happens is that if I try to log in on my local server the session is started but not read by the next file, it returns again to the login screen. The files in the /tmp directory are written and contain the data, but they are not read in again. Can any body help me on this. I work with php 4.3.
View Replies !
How To Differentiate Multiple Sessions?
One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location on the server (in our own accounts on the same machine). When I am testing both versions of our program using the same browser (IE on Windows or Konqueror on Linux) the session variables will mix up and only the latest selection or options will be displayed. If I go back and forth using the "Previous" and "Next" buttons on our pages not only the variables from my pages will change to the variables from his page, but also my page will jump to his page as well. I am wondering if there is a way to specify where to save the session variables on the local machine so later the users can open multiple browsers to lead to different branches of our web site without mixing session variables.
View Replies !
Detecting Multiple Sessions
I have an address database running on POSTGRESQL web based ofcourse with php. My Web application has a login page that gives the users a session_start if their data is correct. Users can login at the same time. I would like to know how i can detect the session from these users. Than i want to know: - How many user are online - Wich users are online When they didn't logged out but have closed their browser, how can i detect if their offline?
View Replies !
Php (or Mysql?) Multiple Sessions
I'm running a script that uses a mysql connect to my local database. The script runs on my local webserver (using wampserver). When I'm running one instance of the script, and I'm trying to start another one, it won't start until the first script is finished. When I run one session on FireFox and the other on Internet Explorer, it does work. Is there some setting I need to change to allow more then one session?
View Replies !
Handling Multiple Sessions??
How do u guys handle multiple sessions?? i.e, opening different browser windows by running iexplore.exe or clicking IE icons and opening the application. My sessions are mixing up. what i mean is suppose i log in my site using username "test". At this time I set $_SESSION['name']="test". And I use $_SESSION['name'] inside my application to print the username. Now if I open another browser & log in with "another test" the session variable is overwritten.Another session is not created. Do you store the session in database or pass the session_id via get or post.
View Replies !
Multiple Sessions With One Client?
Is it possible to have multiple simultaneous sessions with the same client in php? Ive got a web application set up (based on mapserver/chameleon www.maptools.com). In order to server maps, the mapserver app uses the _session var to control certian things. It only uses the session var in very specific instances (ie servin a map). I want to preserve my previously set session info ... Im my simplistic view of things if I could have a second session var, this would be easy.
View Replies !
Correct Handling Of Multiple Sessions
For accessibility reasons I have replaced data being derived from a javascript triple drop down menu on a form feeding to a php page for processing. The replacement method uses a series of pages. A form with radio buttons in an htm page feeds into a similar php page where a session is created - and feeds through to another similar page where a second session is created – with the posted information and the 2 sessions being fed to the final php page for processing. I did not want to use viewers’ cookies – they are often disabled, I’m told. It works. But I am brand new to sessions, and wondering if I have done this correctly. Page1.htm contains a normal radio button form, which posts ”size”. Page2.php has the following at the very top (pre Doctype):
View Replies !
PHP Multiple Instances / Sessions Question
I am currently running 2 instances of a web application on the same server. one of them has address http://www.justanexample.com/prod and the other has an address of http://www.justanexample.com/ipeer_demo. By logging into the demo with the guest passwords, the address becomes http://www.justanexample.com/ipeer_...on=Student.home. I can get into the production instance by simply changing the base url to http://www.justanexample.com/prod/i...on=Student.home and hitting enter. I'm sure there are quite a few solutions to this, but what do you think is the most secure way of overcomming this problem?
View Replies !
Multiple Sessions Disrupting Login Script
Hello, ok i have a very odd problem and i can't seem to figure it out. Basiclly the problem is, i login and logout as different users, and sometimes (im not sure when exactly) but it switches to use a different session file. I used greenarray.php to display all the global variables i am using, and from one page to another i am using different session ID's. Even though my login page has what i beleive to kill the old session: unset($_SESSION['user']); session_unset(); session_destroy(); Shouldn't all those kill the session? But for some reason it will re-read the original session?
View Replies !
Multiple Sessions In Parent-Child Windows
I have a site that has an admin area which lists all the users -- clicking a link within that admin area will then open a new window and automatically log you in as that user. Problem: the session data in the new window overwrites the session data in the original window, so that you are suddenly no longer logged in as an admin in the parent window, but as the user from the popup/child. I believe I want to use session_name() to indicate that these are two separate sessions, right? But session_name() has to be used before session_start() -- so how am I supposed to know which session I am in, so that I can name the session correctly on each page? Am I going to have to pass a variable to every page within the pop-up to indicate which session I am in?
View Replies !
Multiple Level Inlcludes ,sessions And Objects
1.i have a config.php with all my paths variables in it. my question is how do i create a variable which points to config.php, from any ,anywhere in the directory structure at the moment my approach is shown below.also could you tell me if there a better method for doing this. //this is at the top of each page in my site require ('http://'.$_SERVER['SERVER_NAME'].'/allincludes.php'); allincludes.php <?php require ('pageclass.php'); require ('config.php'); session_start(); ?> 2.Some other question will a session started in an included file work for the page it was called from. Also will it work when the session that is started is in file thats two includes down? 3.will a object created in an included file, work for the page it was called from, and will it work even when the object being included is in file two includes down?
View Replies !
Creating User Sessions W/out Using Sessions
I'm working on a user management system where I can use the benefits of PHP sessions w/out messing with them. Basically, my idea is to have an entry created into a "sessions table" when the user logs in. The table contains such info as the user's id number and the date/time they logged in. When the user logs out, the entry is deleted. In each page/script, it checks to see if the user is logged in by checking the sessions table for an entry w/their IP address and the date, to make sure it is fairly current (unless anyone can think of a better way to check). Now my delema....obviously, I don't want people that don't properly log out to have a session that could last weeks (depending on when they visit again). I am thinking a script that cleans up entries that are old would do the trick, but obviously I want this script to run say, at least once an hour. Obviously, I am not going to be able to sit at my computer and run this script every hour of every day. I was thinking of using the script and doing a cron job, but I think my host only allows one cron job per day...and only at night. Any thoughts??
View Replies !
Sessions Help
I am getting strage problems with sessions - actually rarely used them before. I am basically just testing passing a session variable from one page to another. Everything works great when uploaded to my hosting server but not when used locally! Locally I am using Apache 1.3.20 and Php 4.0.6 on win2k with browser IE6 I am using the simplest session setup - PAGE 1 session_start(); $_SESSION['name'] = "Kevin"; echo $_SESSION['name']; Then a link to the second page - PAGE 2 session_start(); echo $_SESSION['name']; As I said everything works great on the hosting server but not locally. I have looked at the output from phpinfo() on PAGE 2 and it shows that the session is being created and even has a value - PHPSESSID=4c0ba2b373b1faf9dfd0c1c98705dfa0 This value showing in HTTP_COOKIE , Cookie and HTTP_SERVER_VARS["HTTP_COOKIE"] The sessions are stored as cookies and if I look in the php/temp directory yup they are there! So it looks like the sessions are being started, store the data in the cookie ok but are not being read on PAGE 2. As I mentioned on the hosting server it works great. Can someone please give us a clue why it isn't working locally? thanks Kevin PS I also tried including a session_register('name') as well as the older $HTTP_SESSION_VARS["name"] = "Kevin";
View Replies !
Sessions That Do Not End?
Does anyone know of anything that would make a session constant even after a user ends the session by closing the browser? I am using sessions to assign users unique id's and when the user comes back to the site, they are being assigned the same session id, therefore making the entire concept useless.
View Replies !
Sessions And IE5 Or 6?
I had sessions working just fine and then all of a sudden they stopped working. I'm wondering if IE5 or 6 handles sessions differently. Anyone had a similiar experience? If not I guess I'm back to the drawing board. If anyone can help me get started with the proper way to start a session I would appreciate it. What I have is a session id and 2 variables. It seems that I can log in and the session is started but when I click on a link on the username page it forgets about the session that was created and I'm back on the login page again with no tracce of the session. <?php session_start(); session_register('username'); session_register('isloggedin'); if (!isloggedin) { loginmenu(); } else { usermenu($username); } ?>
View Replies !
Now You See It, Now You Don't Sessions
This one has me completely stumped. I have a simple site where I'm using sessions to keep track of some information across multiple pages. The trouble is, when I go to a page that displays the information, sometimes I can see the information and sometimes I can't. If I refresh the same page, the information may appear or not in a completely random manner. And nothing is writing to the session variable anywhere in the page. I have displayed the information and it is definitely not there when the information does not appear. I have checked the session id and it remains the same regardless of whether the info appears or not. The code runs fine on my local server (PHP 4.3.2) but not the ISP's server (PHP 4.1.2). My question is - What on earth is going on here? - And if the info is wiped out of the session array on a particular page request, how does it reappear at some random page refresh? Any ideas or thoughts from anyone would be greatly appreciated.
View Replies !
Sessions And CLI
Im currently working on a collection of scripts that will work in command line only. Im using the latest version of PHP. Ive got problems figuring out how to start a session with a specific session_id. Maybe im doing something wrong here, but ive got no idea what. It seams that if I call session_start($id), where $id is a sessionid that i know for sure was already registered earlier, that specific session does not get initialized. See this simple test script PHP Code:
View Replies !
Sessions+ssl
we are using apache OpenSa, with php on a win2k machine, we are having problems with sessions, the sessions are working under the normal apache server,, however when we use the OpenSa ssl component it wont work properly,,,we get the following errors,,,any ideas? Warning: open(/tmpsess_50ca39a0d25cd9d3b98290de9a5379d5, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 i have created the session file in the php folder and put its path into the php.ini file,
View Replies !
Sessions / PHP 4.3.1
I have a website, to which members must "log on" to gain access. The sequence of pages is as follows: 1. index.php Contains form for username/password 2. login.php starts session <? session_start(); session_register("user_id"); session_register("logged_in"); ?> validates authentication A - if "ok" i. sets $user_id and $logged_id ii. goes to membersArea_frameset.php B - if fails - goes to an error page This setup normally works fine, for 99% of visitors. However, every day i get a few emails from people who receive an error message saying that the session has expired, rather than a successful login. Each page (including the above frameset page) has an include of 'session_check.php'. The contents of the file is: <? if ($logged_in != session_id()) { echo "<script>self.location='error.php?error=2'</script>"; exit(); } ?> For nearly all visitors, the above setup works fine. Any ideas why some people are told straight after successfully logging in that their session has expired? This is really worrying. I can't figure it out. Have I not set up the sessions correctly? PHP - Version: 4.3.1
View Replies !
PHP Sessions And IE6
I have a website (e.g. www.mainsite.com) with a MySQL database and I use PHP for members to login, adddel records. Their UserID is recorded in a session variable. I have a second website where the files are located at www.mainsite.com/subdirectory/ and I use framed web forwarding from my ISP which makes it look like www.secondsite.com is actually the contents of this sub directory. I do this because www.secondsite.com is a customised website for that company but accesses the same database. With IE5 when you login to the database via www.secondsite.com it works fine but since i've upgraded to IE6 it gives me a login error. And I remember there is some new Cookie security thing from Microsoft.
View Replies !
Sessions!
i need to create something that will keep the username in 'store' so that it is available to any page on my site that has the members area 2) i need to have code that checks if the 'store' is there, and if the username is in the MySQL db if its there, i need it to display the page content if not...i need it to display a "You are not a member or bad password"
View Replies !
Sessions - SID
I use sessions, if the user doesn't have cookies enabled the query string ?SID=xxx will be at the end of every URL. But...when the user does have cookies enabled this still happens for the first page, an example of a session (urls): http://x.com/ http://x.com/alinkfromxcom/?SID=xxx http://x.com/alinkfrom_alinkfromxcom/ Just a session id on the first link clicked on then it goes away... Does anyone know why?
View Replies !
Is Sessions With 4.1 Different Than >4.x
I've run into some trouble sessions and it seems to be when I upgraded php to 4.1 Is there some documentation that describes the different coding you should use for versions less than or greater than 4.1. Currently I 'm using this main log in page session_start(); $_SESSION["userid"] = "$userid"; $_SESSION["departments"] = "$departments"; and then on every other page I have this at the top session_start(); pretty straight forward if you ask me but for some reason it doesn't want to work and i was just wondering if there was new things that I wasn't aware of.
View Replies !
Ie6 And Sessions
i have a problem with ie6 and sessions in popups. When i open one popup, the session opens as usual, but if i open second popup from the first popup, the session is gone. Has anyone expirienced something similar? anyone knows how to solve the problem?
View Replies !
Sessions In Php 4.1
Our server upgraded to PHP 4.1 on 12/21/01 and now my sessions are not being globally set. 4.1 deprecates session_register(), but still supports it if it is enabled in php.ini which it is on my server. The /tmp is correct and and this smae exact script works on my desktop server using 4.05. When I login to my CMS from an index.php, it opens to the default page, but if you refresh or go to any link, it loses the registered login variables. Anyone else having similar probs? PHP Code:
View Replies !
Sessions Being Ignored
I have my page so that once you login it registered the session variable "logid." This is how I track to see if the user is logged in. This works all well and fine until I try to access that variable from a document thats not in the same directory as the other pages. What am I doing wrong?
View Replies !
Sessions And IE6
Anyone having problems with IE6 and sessions? I have a website with an area where people login and can view numerous pages. They are tracked using PHP sessions and this has worked fine up until this week when a couple of users have reported problems and they both use IE6. They login and once logged in, click on a link to view another page and they are taken back to the login page (which is supposed to happen if a user is not logged in).
View Replies !
Sessions And AOL
I have a site where users register and log in. All the data is stored in a MySQL database. When a user logs in, the username and password is checked in the database and if all ok I set a few sessions. Then at the top of each page I simply check that the sessions have been set and carry on. All this works fine except for users on AOL. They log in but straight away are told that they need to log in. After many weeks of testing different things I'm still confused why it doesn't work. I created a some test scripts as follows to try and get sessions working... aolphpsetup.php <?php ini_set('session.use_trans_sid',1); ini_set('session.use_cookies',0); ?> aolinclude.php <?php if ($_SESSION[s_check1] == 4) { $another_check = "1"; } else { $another_check = "0"; } ?> aoltest.php <?php include("aolphpsetup.php"); session_start(); $_SESSION[s_check1] = "4"; ?> <body> <form name="form1" method="post" action="aoltest1.php"> <input type="submit" name="Submit" value="Click Me"> </form> </div> </body> aoltest1.php <?php include("aolphpsetup.php"); session_start(); header("Location: aoltest3.php?".SID); ?> aoltest3.php <?php include("aolphpsetup.php"); session_start(); include("aolinclude.php"); ?> <body> $_SESSION[s_check1] = <?php echo $_SESSION[s_check1];?><br> $another_check = <?php echo $another_check;?> </body> When running aoltest.php you should click the button and the output via aoltest3.php should produce as expected but it doesn't with an AOL user. I'm using PHP version 5.0.4 and below is the settings of the sessions in my phpinfo.. session Session Support enabled Registered save handlers files user Registered serializer handlers php php_binary wddx Directive Local Value Master Value session.auto_start Off Off session.bug_compat_42 Off Off session.bug_compat_warn On On session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.entropy_file no value no value session.entropy_length 0 0 session.gc_divisor 1000 1000 session.gc_maxlifetime 1440 1440 session.gc_probability 1 1 session.hash_bits_per_character 5 5 session.hash_function 0 0 session.name PHPSESSID PHPSESSID session.referer_check no value no value session.save_handler files files session.save_path /tmp /tmp session.serialize_handler php php session.use_cookies On On session.use_only_cookies Off Off session.use_trans_sid 0 0
View Replies !
Sessions Again
In Win32, php4: (I don't have access to the php.ini file.) With 'session_start()', how do I avoid the complaint "PHP Notice: A session had already been started" ? Without 'session_start()', I get the "Undefined variable: _SESSION " complaint.
View Replies !
PHP Log-out And Sessions
A friend of mine gave me a snippet of a session code that he uses and I've modified it to fit my site, and I can successfully login to my members page. But, I came across another issue and I'm not exactly sure how to approach it, I have a good idea, but thought it would be good to check with you guys (still a hair confused with sessions ). I had a couple friends of mine login using my test account to make sure that the page was displaying properly in different browsers and one of my friends just copied and pasted the url to the members page and was able to view the page just fine, but had a warning about the session.php and it's function. Anyways, what I could make out of it, was that as long as you had the session started on your computer, you could just get right in, and that the same account could be logged in by multiple computers (there were 3 of us at the same time under the same account). So I need to write a piece of code to limit the number of users able to login to one account to 1 and then, if they should exit the page, it logs them out... Here is the session.php that I modified: Code:
View Replies !
|