473,800 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to separate data in Session variable

16 New Member
Hi All,

If someone logs in my system I set up a few Session variables such as user type (admin, user, etc.) and a few other privileges and settings.
Expand|Select|Wrap|Line Numbers
  1.  
  2. session_start ();
  3.  
  4. $_SESSION['id'] = $row['user_id'];  
  5. ...
  6. ...
  7.  
On one server I keep the production version and the test one.

My problem is if I open both versions in different tabs of the same browser both systems read/writhe data form the same $_SESSION variable. I don't want the real(production ) settings to be destroyed while testing.

My feeling is that I should use session_name() function, but I don't know how???

I've just put session_name before the session_start it does not help:(

session_name ('production');
session_start ();

Thanks!
Nov 5 '07 #1
3 1706
Atli
5,058 Recognized Expert Expert
Hi.

So your have two servers, each of them using the the same session data, and you are worried that one of them might damage the session data of the other. Am I right?

If so, you shouldn't have to worry. Each server should have it's own session. One server can't mess up a session on another server.

In any case, the session data is only temporary. It is destroyed when you close the browser (by default). Why are you so worried that it will get damaged?
Nov 5 '07 #2
Beginner1
16 New Member
Hi,

Thanks for reply!!

I have one server on which I keep both versions, so if the same user from the same computer opens the test version all production settings are shown in the test one. That's why I want to separate them somehow.

My customers want to keep their settings available (kept in $_SESSION) for about a week, so I have the following line in my code.

ini_set('sessio n.gc_maxlifetim e', 604800) // 1 week

Thank you!
Nov 6 '07 #3
ak1dnar
1,584 Recognized Expert Top Contributor
My customers want to keep their settings available (kept in $_SESSION) for about a week, so I have the following line in my code.
Thank you!
Then you have to use cookies instead of sessions.
Nov 6 '07 #4

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

Similar topics

1
7790
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains: ---------------------------------------------------------------------------- <?php ini_set("session.use_cookies", "off"); ini_set("session.use_trans_sid", "on"); session_start(); $_SESSION = ""; $_SESSION = ""; echo "<form method='POST' action='login.php'>
2
1772
by: Francisco | last post by:
I have this problem: I have a database with information about games, and users are able to vote for them. Everytime a user votes for a game I store the unique game name into a session variable (an array). So if they are in a page were they already voted, they won't have the option to do so. The idea is that the session cookie lasts "forever", I don't want them voting for the same game everytime they get to the site. This isn't soo strict,...
1
2866
by: db_guy | last post by:
Hi, we have a php-based application that is hosted by Yahoo! Webhosting. Ever since the application was created, it has been plagued by periodic session data loss. Here's a typical example: We will successfully input 7 clients into the system, but upon submitting the 8th, all session data fails to enter the MySQL database. After viewing the record in the database, the row is empty except for data that was not stored in a session. I...
7
1655
by: Mike | last post by:
Hi, I am developing an application with framesets (header, left navigation, and content). Each frameset loads an ".aspx" page, and in one of these pages, I store some information in the Session object, as follows: .... Session = false; ....
10
3236
by: mattmerc | last post by:
Hi all, I posted this about a week back with no response so I want to try again. I have a weird questions in regards to working with sql image data types. I know how to take the image type and convert it into a picture on the screen. What I have is a situation where I need to read the image data from one database, store it, and then upload it to another database. I tried storing it in viewstate and in a byte variable. I don't know if I...
7
2082
by: Steve Mauldin | last post by:
I have a public variable that is declared in a public module. This Variable is stored into a Session variable and used to pass data from page to page. I am seeing on my local development box that once the variable is created and loaded with data and stored into the session variable that on the next aspx page, before the first line of the page load is executed, the public variables data persists. I have not done an assignment from the...
4
1660
by: campwes | last post by:
Hi! I have what I hope is a simple problem. I have 2 web forms. The first form is a welcome page with a textbox and button (in a user control). What's supposed to happen is that a user will enter data in the textbox and click the button. The event handler for the button then has to send that value to a the second web form containing a user control that can accept that value as a parameter in a db query and display the user control...
4
2872
by: Sarah Marriott | last post by:
Our website contains session variables that are used to validate if a user is logged in etc. We have found that these variables are randomly lost while navigating the website. We set up some basic code (as shown below) which used a meta tag to refresh an aspx page every second. It tests whether there is any content in a session variable, if not then it writes a timestamp to a text file, recreates the data in the variable and continues....
3
1333
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
Ok guys, refresh my memory. I have a vague memory from years ago of a Dot Net 1.1 web app in which one window was opened from another (not a message box or anything like that, but a fully separate Internet Explorer. When the finish button was clicked, the second window while closing somehow triggered a refresh in the window that originally called it. What was this technique called?
0
9551
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
10505
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
10276
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
10253
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,...
0
10035
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...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7580
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
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.