• 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 Sanctum CSRF not authenticating

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

Return multiple values from a function using mysqli_fetch_assoc [closed]

Need to display only array value in JSON output

dockerizing Laravel + vue

How to get variable from JavaScript to PHP [duplicate]

calling server using nusoap with complextype

Laravel get user data with profile

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

How to submit a form when page loads using JavaScript?

Popup Window and PHP form

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

if statement inside concatenation

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

Open a popup box after receiving result from ajax

About Contact Privacy policy Terms and conditions