473,387 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How many sessions can I have at one time

155 100+
I'm using this in a form:
Expand|Select|Wrap|Line Numbers
  1. value='"; if (isset($_POST['title'])) echo $_POST['title']; echo "'
The idea was to save the inputs so that if a user had to go back and make a correction they wouldn't have to re-enter all of their information. Nice idea, but it doesn't work. At least not with the above method.

I'm not quite sure what to do at this point. I'm already using a login in session that keeps up with the user's name, user_id, city, etc. But is it possible to use a session to keep up with what they enter into a form text-input and textarea, at the same time as the login session?

Once the information was entered successfully into the database the information in that form session could be vaporized.
Jun 24 '09 #1
5 3511
DavidPr
155 100+
I know there are tons of session tutorials on the web. I've seen them all. See one and you've basically seen them all, since they're pretty much the same tutorial with only the names changed.

They assume that you're only going to use a session for a login feature and that's it. Well, I could use a dozen or more sessions at one time. I have many different forms on a single website.

I use a generic session for a user login. But I could use a different session for this form and another session for that form, and so on and so on. Each form is for a different thing and I don't want the information from one form to get mixed up with another.

What I need is the ability to create a session called "Form 1" and somehow be able take the inputs from "Form 1" and I guess on upon hitting the "Submit" button the user inputs from the form sets a session variable. Maybe like this:
Expand|Select|Wrap|Line Numbers
  1. session_start();
  2. session_name(Form 1);
  3. $_SESSION['first_name'] = $first_name; // from a text input
  4. $_SESSION['dog_name'] = $dog_name; // from a text input
  5. $_SESSION['message'] = $message; // from a textarea
I don't know if the above is correct or not.

How would you take the information one enters in a form and turn them into a session variable?

If there is a form on the "form_1.php" page, and the action is set to go to the "form_1_results.php" page, where would you put what in order to set the session variables so that if the user encountered an error and had to hit the back button to return to the "form_1.php" page the user would not have to re-enter in all of their information again?

And then when they hit Submit again, and this time everything checks out OK the information is entered into the database? AND upon a successful database entry, i.e.,
Expand|Select|Wrap|Line Numbers
  1. $query = "INSERT INTO dogs VALUE ('$first_name', '$dog_name', '$message');
  2. $result = mysql_query($query);
  3. if (mysql_affected_rows() == 1)
  4. {
  5. echo "Information Entered!";
  6. unset($_SESSION['first_name']);
  7. unset($_SESSION['dog_name']);
  8. unset($_SESSION['message']);
  9. session_destroy('Form 1');
  10.  
  11. // unset and destroy this session so they can fill out another form and information won't get mixed up.
  12.  
  13. } else {
  14.  
  15. echo "There was a problem. Hit your "Back" button and fix it.";
  16. }
Is this possible, and if so what would be the proper way of implementing such a thing?
Jun 25 '09 #2
DavidPr
155 100+
I tried using these sessions. I have not tried to unset them yet. The information shows back up in the form OK except for the textareas aren't right. It was showing the textarea information with the \r\n\r\n instead of dropping down two lines.

I used the str_replace and then it just replaced the \r\n\r\n with <br><br>, again instead of dropping down two lines.

To get it to show right I had to do the below - look at the field_content. It works but it seems stupid.


This on the form page
Expand|Select|Wrap|Line Numbers
  1. $field_contact = ""; //default as blank
  2. if (isset($_SESSION['contact'])) $field_contact = $_SESSION['contact']; 
  3.  
  4. $field_contact = ""; //default as blank
  5. if (isset($_SESSION['contact'])) $field_contact = $_SESSION['contact']; 
  6.  
  7. $field_content = ""; //default as blank
  8. if (isset($_SESSION['content'])) $field_content = nl2br($_SESSION['content']); 
  9.  
  10. $field_content = str_replace(array("\\r\\n", "\\r", "\\n"), "<br>", $field_content);
  11. $field_content = nl2br($field_content);
  12. $field_content = str_replace(array("<br>"), "\r\n", $field_content);
  13.  
  14.  
  15. <form>
  16. <strong>Enter Your Contact Info:</strong><br>
  17. <textarea rows='3' name='contact' wrap='virtual'>$field_contact</textarea>
  18.  
  19. <br><br>
  20.  
  21. <strong>Enter Your Classified Ad:</strong><br>
  22. <textarea rows='10' name='content' wrap='virtual'>$field_content</textarea>
And this on the receiving page:
Expand|Select|Wrap|Line Numbers
  1. $_SESSION['contact'] = $_POST['contact'];
  2. $_SESSION['content'] = $_POST['content'];
Jun 25 '09 #3
prabirchoudhury
162 100+
nice.. have look on this articles

Session Handling


Cookies versus PHP Sessions
Jun 25 '09 #4
DavidPr
155 100+
Thanks, I'll take a look at them.
Jun 25 '09 #5
3 years ago maybe..

But session tutorials (per rails) are minimal.
Ive spent 2 days of effort trying to find ways to have multiple users on one project.

Ie; I know that different browsers are doable for same site on same pc.

Or even if server it would be multiple in that sense.

but not so far have I found much else other than 'how to limit simultanious logons (which I wanted too) but even that was limited.

in 3 years documentation hasnt improved while rails has massivley itself.
Oct 9 '10 #6

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

Similar topics

22
by: Theo | last post by:
Question for the group The authentication system for the site Im working on seems to function properly and all is good. A session keeps track of everything and a cookie is used to accept or deny...
1
by: windandwaves | last post by:
Hi Gurus I am basically sorry that I have to bother you about this. I am a PHP beginner and I have been studying sessions and cookies over the last few weeks. I have learned lots, but I am...
9
by: Bartosz Wegrzyn | last post by:
I need help with sessions. I createt set of web site for nav with authorization. first I go into main.php which looks like this: <?php //common functions include_once '../login/common.php';...
19
by: Jeff Clark | last post by:
Hiya! How would i get this number? thanks!
3
by: Maxime Ducharme | last post by:
Hi group We have a problem with sessions in one of our sites. Sessions are used to store login info & some other infos (no objects are stored in sessions). We are using Windows 2000 Server...
2
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...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
7
by: Atte Andr Jensen | last post by:
Hi I'm developing a site where I'd like to store information during a users visit. So far I've been using sessions, but as far as I can tell it's not possible to control for how long a session...
3
by: Atul | last post by:
Hi, I am running .NET Framework 2.0 on windows XP SP2. I am stuck in a situation where I need to find out a list of all active sessions running in IIS for a web application. I know that .NET...
3
Atli
by: Atli | last post by:
Introduction: Sessions are one of the simplest and more powerful tools in a web developers arsenal. This tool is invaluable in dynamic web page development and it is one of those things every...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.