473,788 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sessions not passing properly

I use sessions as part of my login script. One of the values passed is
userid. The userid seems to pass fine into the main part of the page,
but when I use userid in a navigation include I cannot get it to
display.

Here' what I mean.

Code for admin navigation:

function adminMenu(){
echo $userid;
@$result = mysql_query("SE LECT menuid,menulabe l,menuname,url, parent
from crc1.tbluspmatr ix u, crc1.tblmenu
m where
u.privid = m.priv_id and u.userid =
'$userid'
AND parent = '0' AND module_id = '1'
AND
view= '1' AND position='0' ORDER BY
lorder
ASC");
@$counter = 0;
while ($row = mysql_fetch_arr ay($result)){
$path = $_SERVER['PHP_SELF'];
@$class = ( $row['url'] == $path ? 'td_select' : 'td_root' );
echo '<td width=" " valign="top" class="'.$class .' "
style="border-right-width:
1px;border-left-width:
0px;border-top-width: 0px;border-bottom-width:
0px;border-
color: white; border-style: inset;vertical-
align:middle;"> <a id="a_root_'.$c ounter.'"
border="0"
style="cursor:h and; text-align:top;"> <a

class="'.$class .'"onMouseover= "this.style.col or=\'black\'"
onMouseout="thi s.style.color=\ 'white\'"
onMouseout="thi s.style.color=\ 'white\'" href="'.$row
['url'].'">'.$row['menuname'].'</a> </td>';
}//end while

return;
}
?>

I tried echoing out the $userid value, but it did not work. The page
that this include is included in does have session_start() at the top.
I even tried using session_start() at the beginning of the above
function, but that did not work. As I said earlier in the post, the
userid does seem to pass properly to the page mycrc.php, but not to
the adminmenu_func. inc (which is included in mycrc.php).

Any ideas?
Jul 16 '05 #1
1 2596
RG

"Steve Fitzgerald" <sf@mnetsys.com > wrote in message
news:f1******** *************** ***@posting.goo gle.com...
I use sessions as part of my login script. One of the values passed is
userid. The userid seems to pass fine into the main part of the page,
but when I use userid in a navigation include I cannot get it to
display.

Here' what I mean.

Code for admin navigation:

function adminMenu(){
echo $userid;
@$result = mysql_query("SE LECT menuid,menulabe l,menuname,url, parent
from crc1.tbluspmatr ix u, crc1.tblmenu
m where
u.privid = m.priv_id and u.userid =
'$userid'
AND parent = '0' AND module_id = '1'
AND
view= '1' AND position='0' ORDER BY
lorder
ASC");
@$counter = 0;
while ($row = mysql_fetch_arr ay($result)){
$path = $_SERVER['PHP_SELF'];
@$class = ( $row['url'] == $path ? 'td_select' : 'td_root' );
echo '<td width=" " valign="top" class="'.$class .' "
style="border-right-width:
1px;border-left-width:
0px;border-top-width: 0px;border-bottom-width:
0px;border-
color: white; border-style: inset;vertical-
align:middle;"> <a id="a_root_'.$c ounter.'"
border="0"
style="cursor:h and; text-align:top;"> <a

class="'.$class .'"onMouseover= "this.style.col or=\'black\'"
onMouseout="thi s.style.color=\ 'white\'"
onMouseout="thi s.style.color=\ 'white\'" href="'.$row
['url'].'">'.$row['menuname'].'</a> </td>';
}//end while

return;
}
?>

I tried echoing out the $userid value, but it did not work. The page
that this include is included in does have session_start() at the top.
I even tried using session_start() at the beginning of the above
function, but that did not work. As I said earlier in the post, the
userid does seem to pass properly to the page mycrc.php, but not to
the adminmenu_func. inc (which is included in mycrc.php).

Any ideas?

You need to pass the userid to the function
function($useri d)

Your pages main variables have no scope in a function unless you pass them
to it.
Hope this helps
RG

Jul 16 '05 #2

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

Similar topics

5
5943
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page contains: <?php $_SESSION = ""; $_SESSION = "";
0
1470
by: Gleep | last post by:
Hey PHP Gurus, I have some complex scripts that work fine. I have a system where sessions are validated on every page of my application to keep them secure. Everything runs fine when I test and code things. But I am also fanatical about updating the browser for security patches and remove all spyware, virues etc.. But some of my clients are not that savy and that leads me to my first question. Occasionally I have a client complain that...
22
2886
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 access... sounds as it should be I hope. Then when all is done logging out destroys everything and the pages are no longer accessable. Good so far. But two things come to mind: one is preventing multiple logins of the user/password. The...
10
2147
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...
6
2256
by: Rob Meade | last post by:
Hi all, At work we have 2 servers in a cluster for our web apps. One problem we have experienced (along with many others!) - is that if a user is logged into one of the applications on server a for example and it goes offline or fails their session is lost also - even though the application becomes available on server b. I have heard that it is possible to either exchange the sessions between
3
1439
by: Aaron C | last post by:
I'm having a problem passing SESSION variables from page to page. Right now, I have this code at the top of my page: if(!$_SESSION) include "login.php"; This is the code for the login form: if($submit != "") { $login_results = loginCheck($email, $password); if($login_results) { session_start();
7
3340
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 is valid. It seems that these information are valid until the browser closes. On the other hand it's possible to set expiration time for cookies. Does this mean that I have to abanbon $_SESSION altogether and switch to
1
5212
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...
10
662
by: Mike | last post by:
I have had this session issue for months now and I just can't crack it. I have the following 2 scripts... aoltest.php ************* <?php session_start(); $_SESSION = "4"; ?> <a href="aoltest3.php">click me</a>
0
9498
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
10370
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
10177
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
9969
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
6750
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
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
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
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
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.