Jump to content

Multy SESSION in PHP


ebchost

Recommended Posts

a brief description of what I want to do

1. I made a login session, and works without any problems.

2. Any user who logs on to the site, after logging, see the list of programs that create and use the site.

3. Choosing one of the program, which belong to login user, the user can view a list of: payments, invoices, statements, statements that belong only to him within a given program

 

Problem in  3:

I do not want to give for users of applications the ability to see in the link (for examle "index.php?option=programs&userid=1&programs=2") with data such as id, username, or something similar. So I try to do all over the session as in the code below:

list of program for active session - programs.php

<?php

session_start();

//takes on a value for the logged in user id in the session
$indentifikacija = $_SESSION['id'];

$path  = $_SERVER['DOCUMENT_ROOT'];
$path .= "/knjige/resources/init.php";
include_once($path);

$programi = mysql_query("SELECT * FROM `tbl_programi` WHERE `user_id`='$indentifikacija'") or die(mysql_error());
while($row = mysql_fetch_assoc($programi))
{
	$idprg		= $row['idprg'];
	$program	= $row['program'];
	$user_id 	= $row['user_id'];
	$datum	 	= $row['datum'];

                echo " $idprg"; 
                ?>
	<a href='/knjige/modules/mod_izvodi/'>
                         <?php 
                         
                          echo " $program" ; 
                         
                         //taking the value of a variable that contains the session id of program 
                         $_SESSION['idprg']=$idprg	
                        
                         ?>
                </a>

	<?php 
                 echo " $user_id";
	 echo " $datum";
}
?>

 

//taking the value of a variable that contains the session id of program

  $_SESSION['idprg']=$idprg

 

When I in this application click on a program in the list,  for the list of documents in selected programe, code always open a list of documents for the last program (the value of the last variable $idprg)

 

Q1: Is it possible to do something like this

Q2: If it is possible, where I am wrong, and how to perform

 

thanks

 

Link to comment
Share on other sites

You should only store the user-specific data in the session. You shouldn't use sessions to carry dynamic information - that's not what they were designed for.

 

ok, thanks

 

What you recomand for this? (because they secretly want to keep inforamicije such as id, etc.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.