Jump to content

Session reset?


seanj43

Recommended Posts

Is there a way to reset a session?

 

Here is my code...

<?php  
session_start(); 
if (!isset($_SESSION['logged_in'])) 
{
header("Location: login.php");
}

mysql_connect("localhost", "user", "password")or die("cannot connect"); 
mysql_select_db("database")or die("cannot select DB");

$bio = $_POST['Bio'];
$location = $_POST['Location'];
$username = $_SESSION["user_name"];

$sql = "UPDATE users SET bio = '$bio', location = '$location' WHERE username = '$username'";
$result = mysql_query($sql) or die ("Error in query: $sql. " . mysql_error());
?>

 

Now I have a session called bio that I need to reset so that it will store the new bio information. How can I do this? I tried to unset the session and start it again but this didn't work.

Link to comment
https://forums.phpfreaks.com/topic/217151-session-reset/
Share on other sites

it's tough to answer your question, since we have no idea how your session is currently structured or how/where you set the original $_SESSION values. could you not simply use:

 

$_SESSION['bio'] = $bio;

 

to rewrite with the new $bio information? you don't necessarily have to "reset" the session, you can simply overwrite the current variables with the new information.

Link to comment
https://forums.phpfreaks.com/topic/217151-session-reset/#findComment-1127781
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.