473,799 Members | 3,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$_SESSION over two + pages

nathj
938 Recognized Expert Contributor
Hi,

I am trying to get $_SESSION to work on my site. In order to learn this an dunderstand it better I have built two very simple test pages to see if i can access $_SESSION on both pages.

Page 1
[PHP]
<?php /* Created on: 03/07/2007 */
session_start() ;?>
<html>
<body>
<?php
$_SESSION['item1'] = "First session variable";
echo $_SESSION['item1'];
echo '<br /> <a href="session2. php"> click here </a>';

?>
</body>
</html>
[/PHP]

This displays the $_SESSION['item1'] correctly and the link takes you to the second page.

Page 2
[PHP]
<?php /* Created on: 03/07/2007 */
session_start() ;?>
<html>
<body>
<?php
echo 'My first variable: ' . $_SESSION['item1'];
?>
</body>
</html>
[/PHP]

This however, only displays the basic text and nothing comes out from the $_SESSION['item1'].

I am really ew to this idea and I need to understand this is order to get the site I am developing to be properly interactive.

Can anybody see what am missing with this simple example?

Cheers
nathj
Jul 3 '07
19 2192
nathj
938 Recognized Expert Contributor
If your server is running on Windows, you must set the 'session.save_p ath' in your php.ini to a place Apache has permission to use.
This is the folder PHP will use to store the session data, and if it is not set it will not be able to save the data, which causes it to regenerate the session_id every time you call the session_start() method.
Some technical information then:
OS: Windows Vista Business (sorry it's not my fault)
Webserver: IIS 7.0
PHP Version: 5.2.3
Session: Enable and the save_path = "C:\Users\user\ AppData\Local\T emp\php\session " which I do have full permission on.

Interestingly I am also having trouble with php_GD2.dll but one thing at a time I guess.

Thanks for all the help so far, I'm sure we'll get this thing sorted soon.

Cheers
nathj
Jul 4 '07 #11
kovik
1,044 Recognized Expert Top Contributor
Well, check your session_save_pa th() folder to see if the session files are actually there. If not, you don't have valid permissions.
Jul 4 '07 #12
Atli
5,058 Recognized Expert Expert
Session: Enable and the save_path = "C:\Users\user\ AppData\Local\T emp\php\session " which I do have full permission on.
I would recommend moving this out of the Temp thing, to a place like, for example "C:\Inetpub\php sessions\".
It doesn't really matter whether you have access, Apache must have access to it.
Try giving users like 'System' and 'Local Service' access to it, see if that works. You can also try giving everybody access, just to see if this is really the problem.
Jul 4 '07 #13
Purple
404 Recognized Expert Contributor
Hi Nathj

Session: Enable and the save_path = "C:\Users\user\ AppData\Local\T emp\php\session " which I do have full permission on.
can you see session records being stored within this location ?

I am running the same config on my development laptop and had more than a few issues with the new security settings in Vista..

Purple
Jul 4 '07 #14
nathj
938 Recognized Expert Contributor
Hi Everyone,

First of all thanks for all your help so far. I will now attempt to answer all the questions you have asked:

1) (volectricity) Is there anything in the path specified - No, there's not. It is completely empty.

2) (Atli) Apache having access and moving it to another location: I tried moving it to a different location and changed the variable in the ini file but that didnt' make any difference. Also I do not have Apache installed anywhere, I am using IIS 7 as the webserver

3) (Purple) Session records: I'm not entirely sure what I would be looking for here but the path specified is empty. What security issues did you encouter with Vista? I am so fed up with Vista that I am happy to blame it for anything and everything.

Also I thought I should post the debug information as this may help some more:

Warning: Unknown: open(C:\Users\u ser\AppData\Loc al\Temp\php\ses sion\sess_diuuc 9l68mjcpr0tfpla phb2t3, O_RDWR) failed: Permission denied (13) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_pa th is correct (C:\Users\user\ AppData\Local\T emp\php\session ) in Unknown on line 0


I think I have aswered the questions asked. Thanks for the help so far I really appreciate it.
nathj
Jul 5 '07 #15
kovik
1,044 Recognized Expert Top Contributor
Then change the folder to be within the path your server is.

path/to/server/phpsess

It should work.
Jul 5 '07 #16
ocpaul20
7 New Member
I had exactly the same problem yesterday with IIS, win xp pro and php sessions.
I would set a value in $_SESSION['count'] on one page and then it would not appear in the next page although the session id was the same on both pages.

It turned out to be the fact that I had copied a php.ini file which had a
session.save_pa th = "c:/PHP5/sessionfolder"
entry but the actual directory was not there..... as soon as I had created the directory, everything worked as I expected.

Hope that is your answer too.
Jul 6 '07 #17
nathj
938 Recognized Expert Contributor
I had exactly the same problem yesterday with IIS, win xp pro and php sessions.
I would set a value in $_SESSION['count'] on one page and then it would not appear in the next page although the session id was the same on both pages.

It turned out to be the fact that I had copied a php.ini file which had a
session.save_pa th = "c:/PHP5/sessionfolder"
entry but the actual directory was not there..... as soon as I had created the directory, everything worked as I expected.

Hope that is your answer too.
The story at the moment for my session path is that the phpInfo() displays:
C:\Users\user\A ppData\Local\Te mp\php\session

This path is present and is fuly available. The php.ini file lists a path of:
C:\inetpub\phpS ession
Again this path exists and I have full access to it.

The ini file resides in C:\program files\PHP and is the one that phpInfo states is loaded.

This is the only php.ini file I can find on my local system, and as my system is standalone it can't be pulling any from a network location.

I'm really baffled by this and it is now halting development progress - never a nice feeling.

I really appreciate all the help so far and any further thoughts or suggestions are most welcome.
nathj
Jul 6 '07 #18
nathj
938 Recognized Expert Contributor
Hi,

Further to my last post I have done a bit more digging and there are a few mysteries.

1) The phpInfo() reports a different file to the php.ini file, a bit of a mystery.

2) The path that phpInfo() lists I don't seem to have access to, I have tried setting this in Vista and while it says I have full permission it doesn't sem to list the special permissions as being available. However, I don't think that is the problem. I tried, via fopen and fwrite to write to a file in the directory phpInfo lists for sessions and failed, however if I try that to another directory with the same permissions it works fine.

3) I also tried chmod() on the file path in question and was told I did not have permission.

All of this suggests that I should use a different file location but how do I do that if the phpInfo() is not reading from the ini file I have?

Cheers
Nathan
Jul 6 '07 #19
nathj
938 Recognized Expert Contributor
Hi Nathj



can you see session records being stored within this location ?

I am running the same config on my development laptop and had more than a few issues with the new security settings in Vista..

Purple
Hi Purple,

Did you manage to get it working at all? I can see lots of information on the web stating that this is a problem with Vista, but there has to be a solution, doesn't there?

Cheers
nathj
Jul 6 '07 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

4
6166
by: B-B | last post by:
Platform: Win2k Server, Apache 1.3, PHP 4.2.3 I understand that when using $_SESSION variables, using the "session_register()" function should not be done. I have seen no documentation pertaining the the "why" of this, but I am removing the offending statements from my code anyway. Prior to discovering this tidbit, I had been attempting to save some arrrays in individually registered variables. But the arrays were not being saved...
4
12300
by: tornado | last post by:
Hello all, I am not able to find the solution to this problem :(. I have two php pages . On the first page i am getting some values in $_SESSION when i use print_r function. I don't get the values when i use just echo() or print() functions. Now, the first page calls the second php page. But when i try to get the values for $_SESSION on the second page i get empty values even when i use print_r() function. register.globals is set...
5
2977
by: Ken | last post by:
What am I doing wrong? I set the variable co_name on the first page with an <input.... > and session_start() at the top of both pages. Clicking on a link that takes me to the second page: Script on the second page. echo $_SESSION; Does not display
13
23340
by: Mimi | last post by:
Hello, I am having trouble using the session vars in PHP 4.3.9 OS: Win XP Prof Web Server IIS (is local and there are no links to other servers from the web pages I work on) Browser: IE 6.0 The problem I am having is that each time I reload the same PHP page, I get
9
6798
by: Quinonez | last post by:
if i set a $_SESSION=$_POST in every page of a multiple page form how then would i call it on a later page of the same session? and also how is distigushed between pages ? should it be set up differently on each page, ive read of $_SESSION=$_POST but i cant seem to figure out how to call it back at the end of the form
5
13305
by: comp.lang.php | last post by:
Is it possible to access values preset from $_SESSION from within a CLI PHP page? If so, how is it done? Each time I try to access $_SESSION is an empty array; the moment I leave the CLI PHP and return to my calling web-app PHP script, $_SESSION is back again, values and all, completely untouched. Can $_SESSION be called? If not, then I have a bigger problem inasmuch as $_REQUEST variables set via form/query-string MUST be accessed from...
12
41196
by: Michael Windsor | last post by:
I've been trying to integrate some PHP pages of my own with some existing code. The details of this are for the support forums for that code (where I have been asking questions), but I wonder if someone here can enlighten me as to why the problematic code is having the effect it is. For reasons I don't know, if the PHP version is 5 or greater, register_long_arrays is false and $_SESSION exists, the following statement is executed: ...
14
5883
by: Sandman | last post by:
Is there any particular reason I should still use $_POST? Also, I'm reading mixed things about sessions. php.net says you can propagate session IDs either via cookies or session IDs: http://www.php.net/manual/en/ref.session.php#session.idpassing OK cool. However, PHP in a nutshell makes no mention of this. Paul just says hey, use session_start() and you're on your way:
2
2036
by: gm04030276 | last post by:
hey, i'm basically trying to use php sessions and a bit of javascript to make tabbed browsing within a web page using sessions to store the data of the different opened pages. Problem: when i unset the first 0 index in the array (ie close the default page) it seems to wipe the other one (can't get it to add more that one anymore) from the array also the information is held in sub array $_SESSION each page has its own array of infomation...
0
9538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10249
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10219
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7563
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5461
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4138
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.