Jump to content

$decryptedID = base64_decode($_SESSION['idx']);


clausowitz

Recommended Posts

Hi,

 

I have a little code that checks if the user is logged in. Since I moved to another service it doesn't work anymore.

 

<?php
// Start_session, check if user is logged in or not, and connect to the database all in one included file
include_once("scripts/checkuserlog.php");
if (!isset($_SESSION['idx'])) { 
    $msgToUser = '<br /><br /><font color="#FF0000">Only site members can do that</font><p><a href="register.php">Join Here</a></p>';
    include_once 'msgToUser.php'; 
    exit(); 
} else if ($logOptions_id != $_SESSION['id']) {
$msgToUser = '<br /><br /><font color="#FF0000">Only site members can do that</font><p><a href="register.php">Join Here</a></p>';
    include_once 'msgToUser.php'; 
    exit(); 
} ?>

 

 <?php if (isset($_SESSION['idx'])) { 
    
$decryptedID = base64_decode($_SESSION['idx']);
$id_array = explode("p3h9xfn8sq03hs2234", $decryptedID);
$logOptions_id = $id_array[1];
$logOptions_username = $_SESSION['username'];
    $logOptions_username = substr('' . $logOptions_username . '', 0, 15);  ?>

 

Link to comment
Share on other sites

Define: it doesn't work?

 

There could be a dozen different things for the code fragments you posted that could have stopped as the result of moving between different server configurations.

 

Exactly what symptom or error did you see in front of you that leads you to believe - 'it doesn't work'?

Link to comment
Share on other sites

Well before when I logged in I never had any problem getting the message: else if ($logOptions_id != $_SESSION['id']) {

$msgToUser = '<br /><br /><font color="#FF0000">Only site members can do that</font><p><a href="register.php">Join Here</a></p>';

 

but now some pages i can get one and others I get this error.

It must have something to do with the server cause I didn't change anything in the code, just moved the website to another domain.

 

Marco

Link to comment
Share on other sites

I use this on login:

 

<?php $id = $row["id"];   
				$_SESSION['id'] = $id;
				// Create the idx session var
				$_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$id");
                    // Create session var for their username
				$username = $row["username"];
				$_SESSION['username'] = $username;
				// Create session var for their email
				$useremail = $row["email"];
				$_SESSION['useremail'] = $useremail;
				// Create session var for their password
				$userpass = $row["password"];
				$_SESSION['userpass'] = $userpass;
				// GET USER IP ADDRESS
		        $ipaddress = getenv('REMOTE_ADDR'); ?> 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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