Note that there are some explanatory texts on larger screens.

plurals
  1. POhandling with multiple sessions in php
    primarykey
    data
    text
    <p>I have a basic knowledge about websites programming. I want to create a website that has two applications on the same domain. The first would be for the users and the second one would be for the Administrator which is me. That will benefits me to do thing and manage the website without sign in to the database. The question is how to handle with these two session. I tried to use session_name before session_start but it doesn‘t work. I need help to make every session on its own independent side, so they dont mix up with each other. And another question. Is this the right way to set a session when you have multiple?</p> <blockquote> <p>$_SESSION[$variable] = $variable.</p> </blockquote> <p>EDIT: Still not working. This is my code: </p> <pre><code>&lt;?php @$admin = $_POST['admin']; @$password = $_POST['password']; if(empty($admin) OR empty($password)) { echo 'You need to fill all the spaces.'; } if (!empty($admin) AND !empty($password)) { mysql_connect('localhost','root',''); mysql_select_db('job'); $tip0 = mysql_query("SELECT admin, password FROM admin WHERE admin = '".mysql_real_escape_string($admin)."' AND password = '".md5($password)."'"); if(mysql_num_rows($tip0)==TRUE) { $_SESSION['admin']['login'] = $admin; header('location:administrator.php'); echo 'Session has been created'; } elseif(mysql_num_rows($tip0)==FALSE) { echo 'There is no admin.'; } } ?&gt; &lt;html&gt; &lt;body&gt; &lt;form action="admin_login.php" method="POST"&gt;&lt;/input&gt;&lt;br /&gt; Admin: &lt;input type="text" name="admin"&gt;&lt;/input&gt;&lt;br /&gt; Password: &lt;input type="password" name="password"&gt;&lt;/input&gt;&lt;br /&gt; &lt;input type="submit"&gt;&lt;/input&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And this is the redirect page: </p> <pre><code> &lt;?php session_start(); if (isset($_SESSION['admin']['login'])) { echo 'Here we go.'; } elseif(!isset($SESSION['admin']['login'])) { echo 'Not found'; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload