473,811 Members | 3,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sessions not getting updated

Hi,

I posted on this matter earlier with the subject line "Trouble with
sessions," but someone else started a different thread with the same
subject line that arrived before my post, so I'm changing my subject
line in order to avoid confusion.

I was asked to provide a code example for analysis, so here it is,
along with a
a description of what the problem is.

I'm working with sessions and the values for HTML text fields
(input="text") aren't getting updated after the first time I submit
the form. If I shut down my browser and start anew, I can write to the
session just once, as before. On the other hand, radio buttons -- used
with the Sticky Multivalued Parameters script on pages 170-171 of
O'Reilly's "Programmin g PHP" -- are updated every time. Here's an
example of my code. Many thanks to anyone who can make sense of what's
going on here.

Best wishes,

Mountain Man
<html>
<head>
<title>First Form Sessions</title>
</head>
<body>
<form action="form_pr ocessor.php4" method="POST">
First Name: <input type="text" name="firstName " value="<?php echo
$firstName ?>" /><br />
<input type="submit" />
</form>

</body>
</html>

// Next, the form processing script which is on another page.
// In my more complex script of actual use the form is only
// included if it doesn't pass validation.

<?php
session_start() ;
session_registe r("firstName" );
?>

<html>
<head>
<title>Form Processor Sessions</title>
</head>
<body>

<?php
echo "$firstName <br />";
include 'first_form.php 4';
?>

</body>
</html>
Jul 17 '05 #1
1 1794
Mountain Man wrote:
I'm working with sessions and the values for HTML text fields
(input="text") aren't getting updated after the first time I submit
the form. If I shut down my browser and start anew, I can write to the
session just once, as before. On the other hand, radio buttons -- used
with the Sticky Multivalued Parameters script on pages 170-171 of
O'Reilly's "Programmin g PHP" -- are updated every time. Here's an
example of my code. Many thanks to anyone who can make sense of what's
going on here.


Using php version >= 4.1? Then start using the $_SESSION superglobal:

<?

// Enable sessions
session_start() ;

// Get the page URL
$page = $_SERVER['PHP_SELF'];

// Destroy the session var
if (isset($_GET['unset'])) {
if (isset($_SESSIO N['test'])) {
unset($_SESSION['test']);
header("Locatio n: $page");
exit;
}
}

// Update/create the session var
if (isset($_SESSIO N['test'])) {
$_SESSION['test']++;
} else {
$_SESSION['test'] = 1;
}

// Debug output
print "test = {$_SESSION['test']}<br />";
print "<a href='$page?uns et=1'>Destroy session</a>";

?>
JW

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1614
by: Mountain Man | last post by:
Hi, I'm having trouble with sessions. Text fields from a form aren't getting updated when the form is resubmitted. On the other hand, my radio buttons are updated every time. Many thanks to anyone who can help with this. Mountain Man
10
2148
by: Mark H | last post by:
Hey all-- I'm building a database and I basically need to keep out people who aren't authorized, but it's not like I need top security here. I'm just doing basic user/pass of a SQL database, and when a user authenticates I start a session for him. My question is, is there any way for a hacker to easily start a session without having logged in? For instance, if I save the user name and IP address in the session will it be relatively...
15
1861
by: Jazzis | last post by:
I recently moved an application from W2K / IIS5 to W2K3 / IIS6. In the new environment user sessions expire after 2-3 minutes? I can't find any solution to this, although I found quite a few references to this problem on the web. Help anybody? Thanks in advance. Adam
2
2974
by: Steve Franks | last post by:
According to the docs you tell ASP.NET to use cookieless sessions by setting a value in the config.web file. However, what if I wanted to determine at run time whether or not I wanted to use cookieless sessions for a particular user, and if so, I'd instruct ASP.NET to turn on cookieless sessions for a particular user session. Is this possible? For example I want to use cookie based sessions by default for all users. But if a user has...
4
2672
by: Edgardo Sepulveda | last post by:
Hi, one question, is there a limit on the numbers of sessions that a client can have? i dont know why but suddently, as i handle a lot of the user information with sessions, and also have added a lot of new features,, my users are telling me that they are getting session timeout page, that i have for when it happens, but, why now? is there a way that i can count the number of sessions of a client? Thanks for your help, BTW, im using a...
1
5213
by: Duncan | last post by:
I have a strange problem with sessions in PHP 5. I have a simple script that prints a random number both as a string and a picture on the screen. When I run the script for the first time, it works perfectly. However, when I refresh the page, new updated random number does not propagate to the image displayer script through sessions. The image displayer script continues showing the old number instead of the new random number. I checked the...
3
1412
by: Max2006 | last post by:
Hi, Is Page.Cache global and shared between all session? What would be the best way to cache an object and share it btween all sessions? I like to avoid Application object because it doesn't have Cache's flexibilities. Thank you, Max
7
3328
by: deciacco | last post by:
The code below works as expected on my ubuntu linux server 7.04 with LAMP installation.(out of the box) The problem is on my Windows 2k3 Server. It seems the garbage collector never deletes the session file, or deletes it and recreates it immediately, so the script never gets to the "setting session variable" after the first time. I'm using php 5.2.4 isapi.
9
7385
by: Gilles Ganault | last post by:
Hello Some data are common to all user sessions, and to improve performance/save resources, I'd like to share those data between all sessions, so that each user doesn't have to hit MySQL for the same data. I'd rather avoid writing those in a flat file, and keep stuff in RAM instead. Someone told me about cache servers like MemCacheD. I was also given the hints of writing in OO (public class variables) or using
0
10651
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
10393
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...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7671
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
5556
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
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4342
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
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
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.