473,394 Members | 1,567 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,394 software developers and data experts.

How to set a PHP SESSION Variable Value when clicked on <href>

I have a code in PHP, where I trying to set a value of a session variable to '1' only when user clicks on it. Otherwise it should not set the value of session variable.

Expand|Select|Wrap|Line Numbers
  1.       echo '<a href="page2.php?idfilter=' . $filter_sector 
  2.       . '">' .$filter_sector. '</a>';
  3.  
  4.       if(isset($_GET['idfilter'])) 
  5.       {$_SESSION['idfilter'] = $_GET['idfilter']; 
  6.       $_SESSION['counter'] =1;} else { $_GET['idfilter'] =
  7.       '' ;}
Mar 24 '13 #1
2 1959
Rabbit
12,516 Expert Mod 8TB
I'm guessing those two blocks of code are on different pages. You haven't told us what is the problem with the code. Are you getting errors?
Mar 25 '13 #2
johny10151981
1,059 1GB
Your code does not have any problem. But your
else statement does not mean anything except wasting processing time.

And make sure you have started your session in this page. You must have to start your session every page. the concerned function is session_start()
Mar 28 '13 #3

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

Similar topics

3
by: Geoff Winsor | last post by:
Hi, I am experiencing a problem with recalling a session variable which stores whether a person is logged in to a "members only" section of a website. This area of the site has been working...
1
by: crjunk | last post by:
I've got an aspx page that allows the user to select different options whenever they want to run a report. On this page, I have added an additional text box for the user to enter in comments about...
5
by: Marc Rivait | last post by:
Here is a very interesting scenario. I have a simple test application that loads a page and sets a session variable on the load event. On the first page there is a link to a second page. The...
1
by: Shapper | last post by:
Hello, In my Global.asax I set a Session variable named "culture" which has the current culture being used in my web site. In my HTML page I need to preload the images for the current culture....
5
by: rockdale | last post by:
Hi, all: I have a linkbutton and I use javascript to open another webpage in a new window. I also want to set my session variable value when this linkbutton get clicked. These session variable...
1
by: =?Utf-8?B?U00=?= | last post by:
Background We migrated our Asp.net 1.1 application to Asp.net 2.0 ( just migration ) .. It was working fine in local developer machine and one of our development testing server. When we moved...
5
by: aamirghanchi | last post by:
Hi, I need to know if anyone else came across this. The Session variable value I set in a sortCommand event handler of a datagrid does not hold on till the next sortcommand event handler and...
0
by: tharika_c | last post by:
Hi, We have a simple ASP.NET web application where one of the Session variables, called Session("SSO_ID") gets created and assigned a value (equal to the HTTP_HRID request variable value),...
3
by: waqasahmd | last post by:
Hi, I have this code in my pageload but the problem is i want rm_id which i am gettin from session should be set in the javascript code in place of 261 hard code value at line#5( var rmid = 261;) ...
9
dsatino
by: dsatino | last post by:
I'm sure I've actually done this before, so why I can't figure this out now is annoying. I'm hoping someone can spark my memory here. Basically, I have 54 variable names stored in an array. I...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.