• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

Laravel csrf token mismatch for ajax POST Request

how to validate form data in codeigniter 4

Laravel 5 session not persisting after user is logged in

How to check user Permissions using Custom Middleware in Laravel

How do I truncate a decimal in PHP?

Get WooCommerce products from specific category

PHPS source file - 403 Forbidden You don't have permission to access this resource

Using Associative arrays

Insert And Retrieve Data in MySQL with $.post Noob Question

Remove categories with all childs derived from parent category

Why does array_map() with null as callback create an "array of arrays"?

How to get values inside <![CDATA[values]] > using php DOM?

How to fix Call to undefined method AppModelsTableName::factory?

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

PHP header location absolute URL

About Contact Privacy policy Terms and conditions