Sponsored Content
Top Forums Shell Programming and Scripting Multiple PHP sessions within the same browser instance Post 54418 by photon on Thursday 12th of August 2004 03:41:31 PM
Old 08-12-2004
Did you try something like this?

Set cookie:
PHP Code:
<?php

// include function files for this application
require_once('fns.php'); 
session_start();

//create short variable names
$username $HTTP_POST_VARS['username'];
$passwd $HTTP_POST_VARS['passwd'];

if (
$username && $passwd)
// they have just tried logging in
{
    if (
login($username$passwd))
    {
      
// if they are in the database register the user id
       
if( $username == "Administrator"){
            
$HTTP_SESSION_VARS['admin'] = $username;
            
setcookie("cookie[$username]","Admin",time() + 10000000,'/','.website.com',0);
       }else{
            
$HTTP_SESSION_VARS['valid_user'] = $username;
            
setcookie("cookie[$username]",session_id(),time() + 10000000,'/','.website.com',0);
       }  
    }else
    {
      
// unsuccessful login
      
do_html_header('Problem:');
      echo 
'You could not be logged in. 
            You must be logged in to view this page.'
;
      
do_html_url('login.php''Login');
      
do_html_footer();
      exit;
    }      
}
?>
Validate cookie
PHP Code:
<?php
if(isset($_COOKIE['admin'])) {
  echo 
"<p>Hello Administrator</p><br />";
  echo 
$_COOKIE['admin'].'<br />';
  
// after the page reloads, print them out
  
if (isset($_COOKIE['cookie'])) {
    foreach (
$_COOKIE['cookie'] as $name => $value) {
      echo 
"$name : $value <br />\n";
    }
  }
}elseif(isset(
$_COOKIE['valid_user']){
  echo 
"<p>Hello user</p><br />";
}

}else
  echo 
"<p>no cookie for you</p>";
?>
I would think for each admin task do an isset($_COOKIE['admin']).
 

10 More Discussions You Might Find Interesting

1. Solaris

Restricting Multiple loggin sessions

Any idea as to how multiple loggin sessions by the same user (using Hyper terminal/Telnet) be restricted in Sun Solaris 8. Rgds Naushi (10 Replies)
Discussion started by: Naushi
10 Replies

2. Shell Programming and Scripting

Creating multiple sessions

I have a program which gets an input file (which contain a list of objects) and processes the objects one by one sequentially. However when there are many objects it is faster to split the input into smaller lists and run the program in multiple terminal sessions simultaneously. I want to know if... (2 Replies)
Discussion started by: stevefox
2 Replies

3. UNIX for Advanced & Expert Users

Multiple Sessions with FTAM

Just a quick question, Can I establish Multiple Sessions between two machines using FTAM? Regards, Gaurav Goel (0 Replies)
Discussion started by: gauravgoel
0 Replies

4. UNIX for Dummies Questions & Answers

Multiple instance of same process

;)Hi Everyone, I am using solaris 5.10. I have a java process running in server mode in unix. The problem is that it automatically forks i.e creates a child process. I mean suddenly two instances of that process start running , in which the process-id of first instance is the parent... (0 Replies)
Discussion started by: glamo_2312
0 Replies

5. UNIX for Advanced & Expert Users

Multiple Instance Of Same Process

Hi Everyone, I am using solaris 5.10. I have a java process running in server mode in unix. The problem is that it automatically forks i.e creates a child process. I mean suddenly two instances of that process start running , in which the process-id of first instance is the parent... (5 Replies)
Discussion started by: glamo_2312
5 Replies

6. Shell Programming and Scripting

Multiple instance in tomcat

I need to install a tomcat6 with multiple instances like instance1,instance2 and instance3 in a server. I came to know that for that we need to install tomcat6,apache2.0,mod_jk1.2 and jre with tools.jar installed.And we need to create multiple instances with same web.xml and difference... (0 Replies)
Discussion started by: tuxslonik
0 Replies

7. AIX

Multiple sessions with xming

Hi. I installed xming to access to my servers but I have a problem : i can only have one session at a time ... i don't find any parameter to change this. Tks (3 Replies)
Discussion started by: stephnane
3 Replies

8. Red Hat

multiple ssh sessions

Hi, I use OpenSSH to log on to a RH server but when I enter the password 2 session windows appear. I only need one so can anyone advise where I can rectify this? R, D. (2 Replies)
Discussion started by: Duffs22
2 Replies

9. Shell Programming and Scripting

Sessions across multiple scripts.

I wish to be able to pass PHP values between multiple scripts. In each script, I have the following before any HTML code: <?php session_start(); session_name("STORE"); session_set_cookie_params( 'lifetime', '/var/www' ); session_id('Gingy'); ... (1 Reply)
Discussion started by: Meow613
1 Replies

10. UNIX and Linux Applications

Configuring mysql for multiple instance only

Hello. I plan to use mysql with only instance database so I can stop one database for maintenance without stopping every thing. When one reads through the my.cnf config file, it is not clear if we must use at the same time a single database mysql plus any instances mysqld2 (for app1), mysqld3... (1 Reply)
Discussion started by: jcdole
1 Replies
All times are GMT -4. The time now is 03:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy