Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8041805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:20:51+00:00 2026-06-05T04:20:51+00:00

When a user logs in to my website, i create a session called $_SESSION[‘session_city_id’]

  • 0

When a user logs in to my website, i create a session called $_SESSION['session_city_id'] which collects an ID from MySQL

I wonder if it’s possible to change the data it contains from a form. I have created the form select_city which looks like this:

<form name='select_city' action='sessions.php' method='post' style='display:inline;'>
  <select onchange='this.form.submit()'>
  <option value='1'>The first value</option>
  <option value='2'>The second value</option>
  <option value='3'>The third value</option>
  </select>
 <noscript><input type="submit" value="Submit"></noscript>
</form>

My sessions.php looks like this (I just started programming in PHP so don’t bash me for being a complete noob!)

<?php
session_start();
$url = htmlspecialchars($_SERVER['HTTP_REFERER']); //Find out where the user came from

if (isset($_POST['select_city'])){

    $_POST['select_city'] = $city_id;
    
    if (isset($_SESSION['session_city_id'])){
    unset($_SESSION['session_city_id']);
    }
    $_SESSION['session_city_id'] = $city_id;                
}
header ("Location: $url"); //Redirect back to the page the user came from
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:20:53+00:00Added an answer on June 5, 2026 at 4:20 am

    You can just override you session variable with the new value (no need to unset)

    if (isset($_POST['select_city'])){
        $_SESSION['session_city_id']=(int)$_POST['select_city']; // add a better check!
    }
    

    and don’t forget the name in your field

    <select name="select_city" onchange='this.form.submit()'>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine an ASP.NET website which displays stock prices when a user logs in. Can
When a user logs in to a website successfully, that event creates a session
I am creating a website on ASP.Net in which a user logs on and
I'm wondering what is happenning when a user logs in a website with or
I have a website and when the user logs in they can click on
my website has a log in by open id feature. When a user logs
I am building an application in which user logs In, by using username and
My web application sets session every time a user logs in. I checked that
We have a website (foo.com) that does online training. A user logs in, then
I am making a website where a user can create an account and then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.